开发者

I can't see the listbox items in page source

开发者 https://www.devze.com 2022-12-24 02:36 出处:网络
Im adding items to listbox by using jquery but when i look to the page source(html source) ,the items that I\'ve added dont seen.Im adding items by this way

Im adding items to listbox by using jquery but when i look to the page source(html source) ,the items that I've added dont seen.Im adding items by this way

$("#<%=ListBox2.ClientID%>").append("<option value="+exampleValue+"开发者_如何转开发>"+exampleName+"</option>");


You need quotes on attributes, like this:

$('#<%=ListBox2.ClientID%>')
    .append('<option value="' + exampleValue + '">' + exampleName + '</option>');

Also, depending on the browser, it will show the original page's source when you do "View Source"

As an aside: there is a faster approach if adding many elements, since jQuery will cache the fragment:

$('#<%=ListBox2.ClientID%>')
   .append($("<option></option>").attr("value",exampleValue).text(exampleName)); 
0

精彩评论

暂无评论...
验证码 换一张
取 消