I want get input text value when I insert a value in input text
and when i click ADD IN BOOK LIST button jquery will append in booklist ul tag
html code
<form action="" method="POST">
{% csrf_token %}
<p>POST TITLE</p>
<input type="text" name="title" placeholder="Insert title" required>
<p>INSERT BOOK NAME</p>
//user will input value this text box
<input type="text" name="bookname" placeholder="book name">
<input type='button' name="addlist" value="ADD IN BOOK LIST">
<ul class="booklist">
</ul>
<input type="submit" id='button'>//create post button
</form>
I decide to using val() method and i testing using alert()
js code
(function(){
//get ADD IN BOOK LIST button
//get bookname tagname
var addlist_button = $('input[name=addlist]');
var book_name = $('input[name=bookname]').val();
addlist_button.on('click', function(event){
if((book_name == "")||(book_name == null)){
alert('fail');
}
else{
alert(book_name);
}
});
})();
but jquery can't get text value
the val()method is only get value=""in tag inline.. but it is useless value
I want get client's valuable text please somebody help me