jquery val() is not showing value of span
问题 Here i am trying to get value of span that is 1 here .text() is showing proper value but .val() is not showing anyting <span class="commentpageno" id="commentpageno_1111" style="visibility: hidden">1</span> $('.commentpageno').click(function (e) { alert($('.comment_page_no').text()); alert($('.comment_page_no').val()); }); 回答1: val() is not used for span or div it is used for input control like text, checkbox etc The .val() method is primarily used to get the values of form elements such as