Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concatenate string and javascript variable inside jquery selector

How do I concatenate a string with a javascript variable inside a jquery selector? If I execute the code below. All the other form elements gets hidden.

var inputatr = $('input[type=text]').attr(); //button
$('input[value=string ' +  inputatr +']').hide(); //textbox

Update

<?php for($x=0; $x<4; $x++){ ?>

<input type="text" id="<?php echo $x; ?>" name="<?php echo $x; ?>" value="text<?php echo $x; ?>"/>
<input type="button" name="show<?php echo $x; ?>" value="string<?php echo $x; ?>"/></li>

<?php } ?>
like image 809
user225269 Avatar asked Mar 02 '26 03:03

user225269


1 Answers

$('input[value="string' + inputatr +'"]').hide();

This hides the input with the value equal to inputatr

like image 179
Raynos Avatar answered Mar 04 '26 17:03

Raynos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!