Use val()
instead of text()
var hv = $('#h_v').val();
alert(hv);
You had these problems:
- Single quotes was not closed
- You were using
text()
for an input field - You were echoing
x
rather than variablehv
More Related Contents:
- Difference between .on(‘click’) vs .click()
- jQuery how to find an element based on a data-attribute value?
- How do you select a particular option in a SELECT element in jQuery?
- Pass array to ajax request in $.ajax() [duplicate]
- val() vs. text() for textarea
- Animate element transform rotate
- jQuery posting valid json in request body
- javascript capture browser shortcuts (ctrl+t/n/w)
- Load external css file like scripts in jquery which is compatible in ie also
- Unable to set data attribute using jQuery Data() API
- Store JSON object in data attribute in HTML jQuery
- jQuery toggle CSS?
- jqgrid showLink
- Reload table data in Django without refreshing the page
- jQuery .on(‘click’) vs. .click() and .delegate(‘click’)
- Bootstrap 3 jquery event for active tab change
- jQuery Validate Ignore elements with style
- How to change column name in column chooser pop up in jqgrid?
- Validating url with jQuery without the validate-plugin?
- Merge values from two forms on submit
- Check if class already assigned before adding
- jQuery – How to PUT JSON via Ajax?
- jquery function val() is not equivalent to “$(this).value=”?
- map() get() confusion
- Why is the window.width smaller than the viewport width set in media queries
- jQuery CSS() for dynamically created elements
- jQuery behaving strange after page refresh (F5) in Chrome
- Highlight text inside html with jQuery
- jQuery autohide element after 5 seconds
- How do I select the parent form based on which submit button is clicked?