live('click' 不起作用,但在 IE 8 中 .click( workig
live('click' not working but .click( workig in IE 8
我正在使用jquery version 1.3.2
. 我面临一个奇怪的问题。 在IE9中,我的应用程序工作正常,但是在IE8中,此功能不起作用
jQuery('.mutulafriends').live('click',function(){});
我只是在这个函数中放了一个警报,但不起作用,似乎它没有识别click
。 在控制台中,我可以看到一个错误
SCRIPT87: Invalid argument.
jquery-1.3.2.min.js, line 12 character 12949
当我将此功能与警报一起使用时
jQuery('.mutulafriends').click(function(){
alert("");
});
工作完美。 但也显示了错误:
SCRIPT87: Invalid argument.
jquery-1.3.2.min.js, line 12 character 12949
似乎错误不会影响click
. 我知道对于jQuery版本1.3.2 live('change'
不起作用,但是为什么live('clck'
不起作用? 任何想法,请帮忙。 提前谢谢。 这是我的 HTML。 它可能太长了,但我认为它可能会有所帮助。
<div class="component-list-wrapper">
<?php if(is_array($result) && count(array_filter($result)) > 0) {
foreach($result as $record) {
?>
<div class="eliment-component-list eliment-divider">
<div class="user-profile-img-holder">
<img alt="Profile image"
src=<?php if(isset($record['ProfileImg'])){echo $img_url.md5($record['ProfileID'])."/default/".$record['ProfileImg'];}else{echo $this->config->item('ivory_img_path')."/thumb-img.png";} ?> />
</div>
<div class="user-des-container">
<div class="user-des-left">
<div class="namecontainer">
<label class="darkcolour-large"><?php echo $record['FirstName']; if($record['PrivacySettingFriend']){echo " ".$record['LastName'];} ?></label> <label
class="lblsub"><?php echo $record['StateName'].', '.$record['CityName']; ?></label>
</div>
<div class="friendcontainer">
<label img_url="<?php echo $img_url; ?>" req_type="recieved" friend_id="<?php echo $record['ProfileID']; ?>" class="darkcolour margine-top20 mutulafriends btndialogMutualFriends"><?php if(!isset($record['CommonFriendCount'])){echo "0 Friends in Common";}else if($record['CommonFriendCount']!=1){echo $record['CommonFriendCount']." Friends in Common";}else{echo $record['CommonFriendCount']." Friend in Common";} ?></label>
</div>
</div>
<div class="user-des-right">
<div class="user-des-right-inner">
<img width="13" height="13" class="btnDialogDelete request_del_dialog_open_but" req_type="recieved" prof_friend_id="<?php echo $record['ProfileFriendID']; ?>"
src="<?php echo $this->config->item('ivory_img_path'); ?>close_button.png"
alt="Profile image">
<div class="button-wrapper">
<input type="button" class="btnRequest btn-white-small request_accept_dialog_open_but" name="" prof_friend_id="<?php echo $record['ProfileFriendID']; ?>"
tabindex="123456" value="Accept">
</div>
<div class="button-wrapper">
<input type="button" class="btnDialogAssign btn-grey-small request_decline_dialog_open_but" prof_friend_id="<?php echo $record['ProfileFriendID']; ?>"
name="" tabindex="123456" value="Decline">
</div>
</div>
</div>
</div>
</div>
<?php }
} else {?>
<div class="no-records-found">No records found</div>
<?php } ?>
</div>
尝试使用最新的jQuery。它可能会解决您的问题。该版本中可能存在一些错误/缺陷,这些错误/缺陷本可以在更高版本的jQuery中解决。
截至此答案的当前版本是 1.7.2,.live()
已被弃用,它的替代品是 .on()
.
另外,我几乎假设您完全依赖于结束错误警报,该警报最终出现在jQuery库中。信息量不大。检查堆栈跟踪以检查错误可能源自何处。尝试添加断点以了解执行的某个部分的值。我对jQuery有信心,可能只是你为它提供了一些错误的值。还要检查拼写错误。
你的类'mutulafriends'不需要动态绑定,所以'点击'就足够
了把它包进去
$(document).ready(function(){
jQuery('.mutulafriends').click(function(){
alert('And update your JQuery to the latest one :=)');
});
});
委托方法
$(document).ready(function(){
jQuery('div.component-list-wrapper').delegate('.mutulafriends','click',function(){
alert('And update your JQuery to the latest one :=)');
});
});
实时或委托方法仅用于后期绑定,这意味着在页面加载后生成的元素,例如通过 ajax 调用生成
相关文章:
- Fancybox是否将Click事件静音
- jQuery:.click(function(){(element),collapse('show',f
- Angular,表达式{{}}的结果没有插入到ng-click中
- 具有相同类的jquery-click元素
- Ng隐藏在Ng-click元素之外
- document.getElementById(“st”).click();不起作用
- 无法使以下ng on click outside指令在同一页面上的两个元素上工作
- 将代码放入click函数时出现javascript问题
- 将参数中类似形式的ID传递给函数click()
- 如何在ng-click中传递php对象
- 如何将以下“.click”转换为切换
- AngularJs的ng-click$事件将子元素作为目标传递
- angularjs-bindng-click从jquery动态加载DOM
- jsplumb中的Click事件处理程序丢失“;这个“;对象
- jquery on click事件来显示内容
- 如何在javascript中使用click函数选择数组元素
- 使用谷歌图表将mousedown事件注册为click
- jQuery.on-click事件不会发生
- click-cell.bs.table是如何工作的
- live('click' 不起作用,但在 IE 8 中 .click( workig