非常有趣:Javascript到JQuery. [英] VERY INTERESTING : Javascript to JQuery.
本文介绍了非常有趣:Javascript到JQuery.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
请帮忙!!!
我有一个按钮.单击此按钮后,我希望将
Hello,
Please Help !!!
I have a button. On the click of this button , i want all the items in my
列表中的所有项目转移到hiddenfield.
下面的工作,但是,我需要将其转换为Jquery ...:
下面的工作,但是,我需要将其转换为Jquery ...:
list to get transferred to hiddenfield.
The following is working however, i need to convert it into Jquery... :
The following is working however, i need to convert it into Jquery... :
$(''#<% =btnPreview.ClientID %>'').click(function() {
myDivObj = document.getElementById("list2");
if (myDivObj) {
document.getElementById(''<%=hdnSelectedMetrices.ClientID%>'').value = null;
for (var ii = 0; ii < myDivObj.childNodes.length; ii++) {
document.getElementById(''<%=hdnSelectedMetrices.ClientID%>'').value = document.getElementById(''<%=hdnSelectedMetrices.ClientID%>'').value + '','' + myDivObj.childNodes.item(ii).nextSibling.innerHTML;
} }
});
});
推荐答案
(``#<%= btnPreview.ClientID%>'')).click(function(){ myDivObj = document.getElementById("list2"); 如果(myDivObj){ document.getElementById(''<%= hdnSelectedMetrices.ClientID%>'').value = null; 对于(var ii = 0; ii
(''#<% =btnPreview.ClientID %>'').click(function() { myDivObj = document.getElementById("list2"); if (myDivObj) { document.getElementById(''<%=hdnSelectedMetrices.ClientID%>'').value = null; for (var ii = 0; ii < myDivObj.childNodes.length; ii++) { document.getElementById(''<%=hdnSelectedMetrices.ClientID%>'').value = document.getElementById(''<%=hdnSelectedMetrices.ClientID%>'').value + '','' + myDivObj.childNodes.item(ii).nextSibling.innerHTML; } } }); });
将JavaScript转换为jQuery"毫无意义:jQuery只是一个JavaScript库.您在代码中所能做的就是用jQuery快捷方式替换一些DOM调用.
首先,将document.getElementById
替换为
"Convert JavaScript to jQuery" makes no sense: jQuery is just a JavaScript library. All you can do in your code is replacement of some DOM calls with jQuery shortcuts.
First of all, replacedocument.getElementById
with
(selector),几乎就像在第一行中所做的那样.例如,id="list2"
的选择器将是"#list2"
,因此您可以使用此id
替换行,因此第二行的整个内容将是:
(selector), pretty much as you did in your first line. For example, the selector for youid="list2"
will be"#list2"
, so you can replace the line using thisid
, so the whole second line will be:
myDivObj =
这篇关于非常有趣:Javascript到JQuery.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文