簡體   English   中英

extjs函數更改href值

[英]extjs function change href value

我使用extjs進行了以下功能,這些功能可更改單擊的Href和最后一部分:

document.getElementById("#device").href = url;

不管用。
我嘗試使用extjs函數來選擇和更改我的href ...,但結果相同。
任何解決方案或其他方式可以做到這一點?

Ext.select('#tab-home-view ul li a').on('click', function (ev) {
    var url = window.location.href;
    url = url.replace("http://localhost:8080", "");
    Ext.select('#tab-home-view ul li').removeCls('active');
    Ext.get(ev.currentTarget).up('li').addCls('active');
    var current = Ext.get(ev.currentTarget).getAttribute('href');
    url = url + current;
    document.getElementById("#device").href = url;
});

我的標簽:

<div class="tabs" id="tab-home-view">
  <ul class="tab-links">
    <li id="General" class="active"><a href="&activeTabHomeAgregateSite=0">General</a></li>
    <li id="device"><a href="&activeTabHomeAgregateSite=1">Device</a></li>
    <li id="link"><a href="&activeTabHomeAgregateSite=2">Link</a></li>
    <li id="Service"><a href="&activeTabHomeAgregateSite=3">Service</a></li>
 </ul>
</div>

Ext.get()獲得一個ext元素。

您需要在元素上使用屬性dom來修改href 但是, div也是a元素的元素。 所以你需要去down<a>

您可以使用以下Ext.get('device').down('a').dom.href = '/newhref';修改href: Ext.get('device').down('a').dom.href = '/newhref';

這是小提琴表演

擺脫#:

document.getElementById("device").href = url;

那是常規的JavaScript語法。 我對extjs並不是很熟悉,所以我不知道還能嘗試什么。 也許這會有所幫助: ExtJS-如何獲取組件的DOM ID?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM