English 中文(简体)
j Query - toggle 页: 1
原标题:jQuery - toggleClass() highlights <tr> borders in Chrome but not Firefox

Ran into a problem that has stumped me. I want the border of a row in a table to change colors when a user hovers the cursor over them.

这里是我的 j:

$(document).on( hover ,  .song , function()
{
    $(this).toggleClass( highlightRow );
});

这里是我的html:

<table border="1" style="padding-top:0px; margin-top:0px;">
    <tr class="song"><td>test1</td></tr>
    <tr class="song"><td>test2</td></tr>
    <tr class="song"><td>test2</td></tr>
</table>

这里指:

.highlightRow
{
   cursor: pointer;
   border: 2px solid red;
}

它完全在 Chrome进行。 在欧罗尔,曲线向点人变换,这样就是为了把这个类别聚集起来,但边界从未改变肤色。 我为此设立了一个支架(http://jsfiddle.net/5a9k2/7/),并做了罚款。 谁能告诉我,为什么这在吗?

EDIT: ANSWER Thanks to the answer below I realized that TR s cannot have borders. That being said I needed to keep it working with dynamic elements and wanted to highlight every in the row, not just the one hovered over, so my final JS that worked is:

$(document).on( hover ,  tr.song , function()
{
    $(this).children().toggleClass( highlightRow );
});
最佳回答

边界不能适用于“tr”,而是试图“t”。

http://www.ohchr.org。

替换 j 附有:

$("tr.song td").hover(function(){
    $(this).addClass("highlightRow");
},function(){
    $(this).removeClass("highlightRow");        
});
问题回答

Your border css should be: border: 2px solid red;

From: http://www.w3schools.com/css/css_border.asp When using the border property, the order of the values are:

border-width
border-style
border-color

如果上述价值观之一缺失(尽管需要边界),只要其他价值符合具体命令,就不成问题。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Private FireFox plugin

I m looking at getting a FireFox plugin developed - but is it possible to create a plugin that is for private use only, so only those I share it with have it and not open to the masses? Need this for ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Cross-browser development

I m developing a web application for a new service, starting from Firefox 3.5. The interface design is tableless, only using divs + CSS & performance-blessed practices. Now, while being ...

Cross browser way of setting IFrame to "about:blank"?

Does anybody know a proper, cross-browser way to "empty" an IFrame? Is "about:blank" recognized without error across all browsers? Is it valid to give an IFrame an empty src?

热门标签