这是我的 sandbox.php 文件中的一些代码:
<div class="jq">
<img class="active" id="also" alt="Fifty-Fifty?" src="http://placehold.it/350x150"/>
</div>
<div id="title">
This is the alt element of the 350x150 image, found by class. It should return 'Fifty-Fifty?':
<script>
$("#title").text($('.jq .active').attr('alt'));
</script>
</div>
所以,我只是想弄清楚为什么“这是 alt 元素...”被删除,我想知道如何防止这种情况发生。我实际上并不觉得我需要一个“标题”div。我觉得我可以将文本 append 到“jq”部分。
有人可以解释为什么人们也对结构文档感兴趣吗?我正在查看 StackOverflow 的代码,他们将所有链接都放在该 div 的 hlinks-custom
-id'd div 中。 anchor 使其结构分隔变得非常清晰,并且似乎不需要更多的东西。不过,转到 YouTube.com,您会看到页面上的每个链接都有自己的 div。这看起来不奇怪吗?
最佳答案
关于jquery - 为什么 jQuery 会删除我的 DIV 中的内容以及如何阻止它这样做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8401107/