+ 1

how to get input value and set into var selector of jquery?

can i select an id like underwritten in jquery i have used jquery cdn and <script> $(document).ready(function(){ //(let i have get a value from user in input field and store in a var target .) var target = $("input").val(); //now i want to click a btn to make an element with ( id = input value written by user ) , invisible. $("button").click(function(){ $("#"+target).css("display","none") ; }); }); </script> please suggest my mistake bcz i had tried it but that is not working. showing unexpected syntex error in console.

5th Jul 2020, 2:35 PM
Divya Mohan
Divya Mohan - avatar
1 Answer
0
Divya Mohan I am new to jQuery but it would be helpful if you can insert the code in the question or the specific error details
5th Jul 2020, 3:11 PM
Hanuma Ukkadapu
Hanuma Ukkadapu - avatar