2013-01-05 67 views
1

我試了幾個小時在這個網站看,但沒有任何修復我的問題w/onmouseout。 我的onmouseover工程偉大的W/C我也從這個網站的想法,並使其工作。如何刪除onmouseout上的href?

onmouseover="this.href = 'urlHere';" 

我的onmousever是好的,但真正的問題是我的onmouseout。

echo '<td><a onmouseover="this.href=\'main_db.php?page='.$iii_LV.'\'" onmouseout=""> '.$rows_LV['product_id'].'</a></td>'; 

給你什麼,我試圖做一個想法,這是整個代碼的某些部分,我提出:

while($rows_LV = mysql_fetch_array($result_LV)) 
{ 
++$i_LV; 
if ($i_LV%2 == 0) 
{$colorb="#99CFFF";} 
else 
{$colorb="#FFFFFF";}; 
$iii_LV=$i_LV+$ii_LV; 
echo '<tr bgcolor='.$colorb.' onmouseover=" mOver(this)" onmouseout=" mOut(this)" >'; 
echo '<td><a onmouseover="this.href=\'main_db.php?page='.$iii_LV.'\'" onmouseout=""> '.$rows_LV['product_id'].'</a></td>'; 
echo "<td> ".$rows_LV['name']."</a></td>"; 
echo "<td> ".$rows_LV['category']."</a></td>"; 
echo "<td> ".$rows_LV['cost']."</a></td>"; 
echo "<td> ".$rows_LV['retail']."</a></td>"; 
echo "</tr>"; 
}; 

任何幫助將是提前偉大&感謝。 ...

+0

你嘗試過什麼?目前在'onmouseout'事件處理程序中沒有javascript。 – jeroen

+0

onmouseout =「this.href =」「 – str11

+0

@jeroen onmouseout,href attrib不會被刪除,所以我可以在onmouseover之後看到很多強調的'product_id'... –

回答

2

你實際上並不在做任何事情的onmouseout ..你的意思是要做到:

this.href = '' 

請注意,單擊一個空的href實際上可能會返回該頁面,因此您將不得不使用.removeAttribute

既然你有,倒不如單獨綁定的事件,你會得到更多的靈活性也:

$('a').hover(
    function() { 
     $(this).attr('href', 'urlHere'); 
    }, 
    function() { 
     $(this).removeAttr('href'); 
    } 
); 
+0

我收到了您的答案,謝謝並對我的jquery noobness抱歉,但它不工作...你可以請更詳細的語法上我應該把什麼** onmouseout =「」**我的意思是,我如何確切地把_.removeAttribute ** onmouseout **? –

+0

順便說一句,很多謝謝你的答覆我明白了,你給了我一個想法... –

+0

onmouseout =「this.removeAttribute(\'href \')」感謝所有的答覆,我花了一些時間弄清楚,因爲一些給出的解決方案並不是特定的,我仍然對jquery/javascript感興趣,再次抱歉!無論如何,這段代碼有點短了,得到了我想要的結果......但是再次感謝所有幫助過的人 –