I want to get input value but it inside li tag;
$(".enter_click").click(function() {
var enter_click = $(this).children(".enter_click_id").val();
console.log(enter_click);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<li class="enter_click">
Click me
<input type="hidden" class="enter_click_id" value="hidden value">
</li>
Original HTML for input:
<input type="hidden" class="enter_click_id" value="' + value.id + '">
When the li
is clicked I want to get the value of the input
inside it. Even if I bind the click function directly to the input
I cannot click because the input has no size.
When I write the li tags directly as html, the function works, but my li tags are added instantly with the javascript append function. I have a search bar. The data containing the characters written to the search bar are pulled from the json file and added to the ul tag with #result id. It doesn't work when you do it like this
<input type="input" name="search" id="search" placeholder="Type something" class="form-control" onfocusout="focus_out()"/>
<div style="position:relative;width:470px;">
<ul style="text-align:left;" class="list-group" id="result">
</ul>
</div>
<script>
$.each(data, function(key, value){
if (value.name.search(expression) != -1 || value.location.search(expression) != -1)
{
$('#result').append('<li class="enter_click list-group-item link-class"><input type="hidden" class="enter_click_id" value="'+value.id+'"><img src="'+value.image+'" height="120" width="120" class="img-thumbnail" /> '+value.name+' | <span class="text-muted">'+value.location+'</span></li>');
}
});