如何if在JavaScript中使用内联语句?还有内联else声明吗?
像这样的东西:
var a = 2;
var b = 3;
if(a < b) {
// do something
}
Run Code Online (Sandbox Code Playgroud) javascript if-statement ternary-operator conditional-operator
如何使用jquery ???从数组中找到单击的锚标记的索引?
我想搜索是否存在eqqal单击元素的元素,如果为true则返回该元素的索引.
我试过这样的东西,但它以-1返回
$('#id').click(function(){
var obj = $('a').get(0).href;
var arr = $.makeArray(obj);
var getclickedhref = $(this).get(0).href;
var clickedindex = $.inArray(getclickedhref, arr);
console.log(clickedindex);
});
Run Code Online (Sandbox Code Playgroud)
请你能帮帮我吗??!