我如何使它可点击 [英] How Could I Make The It Clickable
本文介绍了我如何使它可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var arrayLength = resultArr.length;
for (var i = 0; i < arrayLength; i++) {
$("#result").text(resultArr[i].label);
$("#result").click(function () {
window.location.href = resultArr[i].value;
}
)
我显示一个名字,名字也有一个值当你点击一个href转到那个页面的名字时,我想要一个链接
i现在得到这个错误:
错误:无法获取未定义或空引用的属性'resultArr'
I display a name and the name also has a value with a link i want when u click the name thats a href go to that page
i get this error right now:
Error: Unable to get property 'resultArr' of undefined or null reference
推荐答案
( #results)。text(resultArr [i] .label);
("#result").text(resultArr[i].label);
( #results)。click(function(){
window.location.href = resultArr [i]。 value ;
}
)
("#result").click(function () { window.location.href = resultArr[i].value; } )
我显示一个名字,这个名字也有一个带有我想要的链接的值当你点击href转到那个页面的名字
i现在得到这个错误:
错误:无法获取未定义或空引用的属性'resultArr'
I display a name and the name also has a value with a link i want when u click the name thats a href go to that page
i get this error right now:
Error: Unable to get property 'resultArr' of undefined or null reference
尝试一下,如果您需要其他任何内容,请告诉我。
//// JQuery / ///
Try it, and let me know if anything else you require.
////JQuery////
var resultArr=[{"label":"Google","value":"https://www.google.co.in/"},{"label":"Yahoo","value":"http://www.yahoo.com/"},{"label":"Rediff","value":"http://www.rediff.com/"},{"label":"Youtube","value":"http://www.youtube.com/"}];
var arrayLength = resultArr.length;
var str="";
for (var i = 0; i < arrayLength; i++) {
str+="<a href='"+resultArr[i].value+"'>"+resultArr[i].label+"</a></br>";
}
这篇关于我如何使它可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文