【发布时间】:2011-10-04 06:20:23
【问题描述】:
在 html 代码中,我使用的是代码
<input type = "text" id = "abc@def.com"> 获取文本
现在它需要获取在文本字段中输入的值。我正在使用 jquery 来做到这一点:
$( document ).ready( function() {
$( ".bid" ).click( function() {
idVal = this.id
bidID = "#" + idVal + "bid"
spanID = "#" + idVal + "cbid"
bidValue = $(bidID).val();
alert(idVal)
alert(bidID)
alert(bidValue) //this alert says undefined
$( spanID ).html( ' ' ).load( '{% url online_machines %}?id=' + idVal + '&bidvalue=' + bidValue);
});
});
通过这样做,我得到未定义的值错误。 我试图从 id 中删除特殊字符以获取其值。但我需要带有特殊字符的 id。怎么能 我使用 jquery 获得它的价值?
【问题讨论】: