2016-02-27 109 views
0

我的工作,我需要写一些JS只有我不能用户的库如jQuery网站...jQuery来香草JS

我需要重写代码是一个简单if statement

$(document).ready(function() { 

    var totalP = $('#shopping-cart-totals-table tr:first .a-right .price').html(); 
    totalP = parseFloat(totalP.slice(1)); 

    if (!window.location.href.indexOf("gpf") > 0) { 
    $('ul.sp-methods li:first-of-type').hide(); 
    } else if (window.location.href.indexOf("gpf") > 0 && totalP < 100){ 
    $('ul.sp-methods li:last-of-type').hide(); 
    } 

}); 

我怎么会去定位元素,如...

var totalP = $('#shopping-cart-totals-table tr:first .a-right .price'); 
+2

http://youmightnotneedjquery.com/ –

+0

您需要了解JavaScript DOM遍历。 document.querySelector可能会帮助你。 –

回答

0

使用方法.querySelectorAll()要么document或DOM元素上。