おそらく次のようなもの
$('div[id^=Item_] div.text');
また
$('div[id^=Item_] a.Link');
あなたの編集に応じて
これを試して
function call(e) {
// Find the inner anchor
var theAnchor = $('div[id=Item_' + e + '] div.text').find('a.cancel');
}
呼び出しまたはjQueryコードのいずれかにアンダースコアがないため、IDを持つdivを探しています
Item23
IDではなく
Item_23
これは、他のリンクがクリックされたときにキャンセルリンクを取得する方法を示すJSFiddleです。
http://jsfiddle.net/PyDKg/14/
@undefinedが示唆しているように、jQueryを使用しているので、インラインjavascript呼び出しは必要ありません。関数を少し変更したので、親のIDを取得し、ID全体をパラメーターとして送信します。
HTML
<div id="Item_23">
<div class="Info">
<a class="Link" href="#">Link</a>
<div class="text">
<a class="cancel" href="cancel.asp" data-val="Yay got it!">Cancel</a>
</div>
</div>
</div>
JS
$(document).ready(function(){
$('a.Link').click(function(){
var id = $(this).parents('div[id^=Item_]').attr('id');
callAnchor(id);
});
});
function callAnchor(e) {
// Find the inner anchor
var theAnchor = $('div[id=' + e + '] div.Info div.text').find('a.cancel');
// Print the data-val attribute to prove that it was found.
alert($(theAnchor).attr('data-val'));
}