HTML:如何通過Jquery獲得直接父項?
<span class="ui-spinner ui-widget ui-widget-content ui-corner-all"><input class="spinner1 ui-spinner-input" id="q1" name="value" value="1" min="1" aria-valuemin="1" aria-valuenow="2" autocomplete="off" role="spinbutton"><a class="ui-spinner-button ui-spinner-up ui-corner-tr ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button" aria-disabled="false"><span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-n">▲</span></span></a><a class="ui-spinner-button ui-spinner-down ui-corner-br ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button" aria-disabled="false"><span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-s">▼</span></span></a></span>
的jQuery:
$('.ui-spinner-button').click(function() {
//
});
我想詠歎調 - valuenow的ID和值
<input class="spinner1 ui-spinner-input" id="q1" name="value" value="1" min="1" aria-valuemin="1" aria-valuenow="2" autocomplete="off" role="spinbutton">
當我點擊.ui-spinner-button
我該怎麼做。我搜索了幾天,但沒有運氣。
您可以使用.parent ()來獲取父項。 – nikhil
'$(this).prev()。attr('aria-valuenow')或$(this).siblings('。spinner1')。attr('aria-valuenow')' – Jai
使用'$(this)。分組( 'UI微調輸入 ')。ATTR(' 詠歎調-valuenow')' – Satpal