asd*_*hak 2 ajax jquery document-ready
here is my case:
<html>
<body>
<head>
...
<script>
$(function(){
$('.do-tip').qtip({
content: 'This is a tip of active hovered element',
show: 'mouseover',
hide: 'mouseout',
})
});
</script>
</head>
<body>
<a href="http://www.google.com" class="do-tip">google</a>
<input type="button" value="load div by ajax" />
<div> <!-- this div loaded by ajax -->
<div>
<a href="http://www.yahoo.com" class="do-tip">yahoo</a> <!-- HOW TO HERE, run the existing script only for this part, JQUERY UNCLE must have a solution-->
</body>
</html>
any ideas?
Run Code Online (Sandbox Code Playgroud)
虽然我不清楚你要做什么,但我会尝试使用我的MagicGuess工具并为你提供答案.
所以,你需要
a)对文档加载执行一些功能; 此功能.do-tip对页面上的所有元素执行某些操作
b)通过AJAX加载东西后执行相同的功能,但现在需要使用另一组元素进行操作.
真的吗?如果是这样,我会这样做:
function doEverythingINeed(selector) {
$(selector).qtip({
content: 'This is a tip of active hovered element',
show: 'mouseover',
hide: 'mouseout',
})
}
$(function() {
doEverythingINeed('.do-tip');
});
Run Code Online (Sandbox Code Playgroud)
doEverythingINeed通过AJAX加载HTML后调用另一个选择器.如果你使用$.ajax()函数,那么你应该这样做
$.ajax({
//parameters
success: function() {
//some other actions if needed
doEverythingINeed('your selector');
//more actions if needed
}
});
Run Code Online (Sandbox Code Playgroud)
希望有所帮助!
| 归档时间: |
|
| 查看次数: |
4123 次 |
| 最近记录: |