2013-07-15 51 views
0

我想從運行jQuery的方法中的href沒有點擊錨link.Please看到下面......jquery - 能夠在jquery方法中運行href嗎?

<a id="excelExport" class="actionButton" alt="Export to Excel" title="Export to Excel" href="pexport" ></a> 

我需要調用Action類,而不是上面的代碼..

function method() 
{ 
    href="action"; // to action class... 
} 

我們可以在JQuery中使用任何類似的函數嗎?

+0

也許這是明智的開始與基本 - > http://jquery.com/ – adeneo

+0

嘗試普通的舊JavaScript:document.location.href =「...」。 jQuery不是一個神奇的子彈。 –

+4

或更好的window.location,因爲document.location已被棄用,並且應該是隻讀的 – mplungjan

回答

2

如果我得到你的權利,你想是這樣的:

普通的JavaScript

function method() { 
    window.location.href = "action"; 
} 

jQuery的對手將是:

function method() { 
    $(location).attr('href', 'action'); 
} 

雖然我跟老堅持出於兼容性原因的純JavaScript方法。

+0

@rtpHarry感謝編輯,我看到了錯誤,但認爲我保留了與原始文章相同的語法:) – intuitivepixel