我一直在玩jQuery,只是尝试在点击链接和隐藏/显示内容项目时替换文本字段。它似乎在IE中工作得很好,但我似乎无法让它在FF中工作。初学jQuery问题(FF/IE问题)
我的jQuery:
$(function() {
$(".articles a").click(function() {
articlenumber = "1"
$(articlenumber).css("display", "none");
articlenumber = $(this).attr("id");
articlename = $(this).attr("name");
articlenumber = '".' + articlenumber + '"';
//alert(articlenumber);
//$(articlenumber).css("display", "inline");
$(articlenumber).attr("style", "display:inline;")
$(".articletitle").text(articlename)
});
而我的HTML这个(简体):
<a id="article1" name="Article Title1" href="#">Link</a>
<a id="article2" name="Article Title2" href="#">Link</a>
<div class="articlename">Title</div>
<div class="article1" style="display:none;">Text 1</div>
<div class="article2" style="display:none;">Text 2</div>
任何建议,这是为什么不能在Firefox工作?还有什么我可以在这里清理?
将var添加到开头似乎没有改变FF中的任何内容,IE仍然正常工作。在这种情况下,我只是宣布它,但我需要这些值为字符串。 – user466459 2010-10-05 05:17:52
您已经多次使用相同的'id'。 'id'属性是唯一的。另外,看起来你使用'articlenumber'作为选择器,这很奇怪,因为这会选择不存在的'1'元素。 – 2010-10-05 05:20:21
你正在使用萤火虫吗? http://getfirebug.com/ – 2010-10-05 05:20:37