先生, 我需要使用jQuery的標籤td
,tr
和div
包含onmouseout
和onmouseover
添加元素添加屬性。的jQuery中的元素TR,TD和DIV
如果發現onmouseout="ANY FUNCTION"
然後我需要添加屬性onblur="SAME FUNCTION AS onmouseout"
。
那麼,如果發現onmouseover="Any Function"
然後我需要添加屬性onfocus="sane functions as onmouseover"
。
此功能包含在標籤td, tr or div
。
如TD:
<td onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="zz1_GS">
然後我需要:
<td onmouseover="Menu_A(this)" onfocus="Menu_A(this)" onmouseout="Menu_Unhvr(this)" onblur="Menu_Unhvr(this)" onkeyup="Menu_Key(this)" id="zz1_GS">
例TR:
<tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="zz86756f">
那麼我需要像這樣:
<tr onmouseover="MDynamic(this)" onfocus="MDynamic(this)" onmouseout="Menu_r(this)" onblur="Menu_r(this)" onkeyup="Menu_Ky(this)" id="zz86756f">
例格:
<div class="1_5656" id="d867444f" onmouseover="PopOUp(this)" onmouseout="PopOStop(this)" style="text-align:center;">
然後我需要的東西是這樣的:
<div class="1_5656" id="d867444f" onmouseover="PopOUp(this)" onfocus="PopOUp(this)" onmouseout="PopOStop(this)" onblur="PopOStop(this)" style="text-align:center;">
ID名稱不一樣而td和tr的水平並不一致。
誰能幫我實現這一目標?
我做這個代碼,但它不工作:
$('div[onmouseout]').each(function() {
$(this).attr('onblur', $(this).attr('onmouseout'));
}
$('div[onmouseover]').each(function() {
$(this).attr('onfocus', $(this).attr('onmouseover'));
}
$('tr[onmouseout]').each(function() {
$(this).attr('onblur', $(this).attr('onmouseout'));
}
$('tr[onmouseover]').each(function() {
$(this).attr('onfocus', $(this).attr('onmouseover'));
}
$('td[onmouseout]').each(function() {
$(this).attr('onblur', $(this).attr('onmouseout'));
}
$('td[onmouseover]').each(function() {
$(this).attr('onfocus', $(this).attr('onmouseover'));
}
你試過了什麼? 。 – Vladimirs 2013-04-05 14:34:06
令人困惑的問題,不能ü闡述:( – dreamweiver 2013-04-05 14:34:26
請不要使用'onwhatever'屬性觸發JavaScript的它更容易,從長遠來看,要添加使用['。對()']的處理程序(HTTP:// API .jquery.com/on) – Blazemonger 2013-04-05 14:35:59