简体   繁体   English

JQuery无法找到我的元素。为什么?

[英]JQuery can't find my Element. Why?

UPDATE: Silly me didn't notice that the CASE wasn't exact. 更新:愚蠢的我没有注意到CASE不准确。 I was struggling with this for 30+ minutes, and you guys saw my problem in less than 5!! 我在这场比赛中奋斗了30多分钟,你们在不到5分钟内看到了我的问题! thanks for saving me a lot of grief - I'm kind of new to programming anyway,I need to learn how to look out for little things like this, but thanks so much, it had not even crossed my mind:) 谢谢你给我带来了很多的悲伤 - 无论如何我对编程都很陌生,我需要学习如何寻找像这样的小东西,但非常感谢,它甚至没有超出我的想法:)

Sorry everyone - It was misleading before because I forgot to put quotes in my question, but I can assure you I know that the selector for Jquery requires quotes and I've been using them... 对不起大家 - 之前有误解,因为我忘记在我的问题中加上引号,但我可以向你保证我知道Jquery的选择器需要引号而且我一直在使用它们......

<div id='question' style="background-color:#DAE2E8;border-color:#A2B3C7;border-width:1px;border-style:solid"><br /> 
    <table id='searchtable' border='0'>
        <tr>
            <td><span class="label">Question ID:</span><input id='QuestionId' type='text'/></td>
            <td><span class="label">Question Title:</span><input id='QuestionTitle' type='text'/></td>
            <td><span class="label">Original URL:</span><input id='OriginalURL' type='text'/></td>
            <td><span class="label">Original Title:</span><input id='OriginalTitle' type='text' /></td>
            <td><span class="label">Chronic ID:</span><input id='ChronicID' type='text' /></td>   
        </tr><tr>
            <td><span class="label">Expert Name:</span><input id='ExpertName' type='text'/></td>  
            <td><span class="label">Topic ID:</span><input id='TopicID' type='text'/></td>
            <td><span class="label">Channel ID:</span><input id='ChennelID' type='text''/></td>
            <td><span class="label">Funded: </span><input id='IsFunded' type='text'/></td>
            <td><span class="label">Funded Partner:</span><input id='FundedPartner' type='text'/></td>
        </tr><tr>
            <td><input type="submit" value="Submit" onclick='ApplyNewFilters(this)' /></td>
        </tr>  
    </table>
</div>

So here is my HTML code (its in an aspx page) - I tried using $("#QuestionID").val() to get the value, but it won't work. 所以这是我的HTML代码(它在aspx页面中) - 我尝试使用$("#QuestionID").val()来获取值,但它不起作用。 I also tried $("input#QuestionID").val() . 我也试过$("input#QuestionID").val()

Try using: 尝试使用:

$("#QuestionId").val()

Note the quotes and exact case. 请注意引号和确切的大小写。

Example here 这里的例子

Are you sure you are using the correct case ? 你确定你使用的是正确的盒子吗?

$("#QuestionId").val() should work $("#QuestionId").val()应该有效

If it is not working, go and check your firebug console tab to see whether there is some script error in the page 如果它不起作用,请检查您的firebug控制台选项卡以查看页面中是否存在某些脚本错误

输入ID是QuestionId而不是QuestionID

The selectors are case-sensitive, so you've mispelled the "Id" 选择器区分大小写,因此您错误地将“Id”拼错了

$("#QuestionId").val()

Should work. 应该管用。

You're missing the quote marks on your selectors. 你错过了选择器上的引号。 It should be $('#QuestionId').val() or $('input#QuestionId').val() 它应该是$('#QuestionId').val()$('input#QuestionId').val()

尝试更正该行的双引号

<input id='ChennelID' type='text''/>

look

<td><span class="label">Channel ID:</span><input id='ChennelID' type='text''/></td>

and this 还有这个

<td><span class="label">Channel ID:</span><input id='ChennelID' type='text' /></td>

you have and extra ' at the end 你最后有额外的

in case you are using 如果你正在使用

<asp:TextBox /> 

you must create a var on javascript with the value of the asp client id 你必须使用asp客户端id的值在javascript上创建一个var

var ChannelID = <%=txtChannelID.ClientID %>

where clientid is the text box name 其中clientid是文本框名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM