i need get attribute name for selector another element this is my html code
//I've tried this but it does not work or maybe there is something wrong
/* $(document).ready(function() {
$('#btnadd').click(function() {
alert($(this).attr('name'));
});
}); */
function addval() {
var btnini=$(this).attr("name");
$("#txt"+btnini).show();
$("#btn"+btnini).show();
$(this).css("display","none");
}
<!-- I've tried this but it does not work or maybe there is something wrong
//<button type="button" id="btnadd" name="opsional">Tambahkan</button> -->
<input type="text" id="txt-opsional" style="display:none;" />
<button type="button" onClick="addval()" name="opsional">Tambahkan</button>
<button type="button" id="btn-opsional" style="display:none;">simpan</button>
when i click button "tambahkan", textbox id="txt-opsional" and button id="btn-opsional" will show, so button "tambahkan" will hidden
I hope there is a better suggestion Thank You