2016-11-21 2 views
0

Jqueryを使用して、カスタムアクション(リボン)の親アンカータグのIDをsharepointに取得しようとしていますが、取得できません。 私のHTMLはカスタムアクションの親アンカータグのIDを取得するには?

<a unselectable="on" href="javascript:;" onclick="return false;" class="ms-cui-ctl-large " mscui:controltype="Button" role="button" id="{E549A47E-BA3E-4D2B-A496-5B9C077A875F}-Large"> 
    <span unselectable="on" class="ms-cui-ctl-largeIconContainer"> 
    <span unselectable="on" class=" ms-cui-img-32by32 ms-cui-img-cont-float"></span> 
    </span> 
    <span unselectable="on" class="ms-cui-ctl-largelabel">Custom Action<br></span> 
    </a> 


と同様に、このスクリプトは

<script type="text/javascript"> 
    $(document).ready(function(){ 
    var ttle=$("input[title='custom Action']")[0].parent().attr('id'); 
    alert(ttle); 
    });                        
</script> 
ここ


は、画面のスナップ
enter image description here あるIDを取得するためにaplyingていますされているが、それはあるようです働いていない。
そのための解決策はありますか?

+1

この場合、HTMLを投稿してください! –

+0

あなたはこれを試すことができます。 '$(" input [title = 'カスタムアクション'] ")。parent()。attr( 'id')' – Aruna

+0

サンプルコードを追加できますか? – Nitheesh

答えて

0

この「$("input[title='custom Action']")[0]」はdomオブジェクトです! 別の$記号でそれをカバーすればうまくいくでしょう!

var ttle=$($("input[title='custom Action']")[0]).parent().attr('id'); 
alert(ttle); 
+0

それはまったく意味がありません。 [0]を置き換えるだけで、Jqueryオブジェクトを取得することができます。 – SiriSch

+0

警告ボックスに未定義のテキストが表示されています – Madhav

関連する問題