【发布时间】:2012-05-04 00:11:42
【问题描述】:
是否知道让 javascript/jquery 仅适用于 div 或 iframe 内的所有内容的方法?
例如: 我有一个很酷的 javascript 函数,它可以让我的文本改变颜色,但是当我只希望它改变 div 或 iframe 中的文本时,它会改变整个文本页面的颜色。
有什么想法吗?
这里有一些代码:
<script type="text/javascript">
$(document).ready(function() { // When the document is ready
$.foo({
fontchange: true, // Make the text pretty
});
});
</script>
编辑:这似乎比它的价值更麻烦,谢谢你的帮助。
【问题讨论】:
-
代码值一千字。
-
在编写您的 javascript/jQuery 代码时,您会指示它如何操作以及影响页面的哪些部分。我们需要查看代码才能评论要更改的特定部分。很多 jQuery sn-ps 就像
$('everything').myPlugin();一样简单,您只需将其更改为$('subset-of-everything').myPlugin();。 -
@McDan Garrett:感谢您的代码。请参阅我的更新答案。
标签: javascript jquery iframe html