I am trying to trigger alert on button click when ever a text is entered on an input field
<script type=text/javascript>
$(function() {
$('#buttonVal').click(function() {
<input id="messageID" type="text"/>
var newAlert = $("input#messageID"),
newAlertOk = $newAlert.val();
alert("this is new alert "+newAlertOk);
</script>
When I click the button nothing happens. Please where am I wrong? I have editted to include click event
click
event handler attached to your button? can you add a bit more code or a fiddle?