I’m trying to get data from these fields
<input type="text" id="distance1" placeholder="FROM"/>
<input type="text" id="distance2" placeholder="TO" />
<button id="distCalculate">Calculate!</button>
into jQuery to do something with them. But, this is not working:
jQuery(document).ready(fucntion(){
jQuery('#distCalculate').live('click', function() {
alert('hi!');
var d1 = $('#distance1').val();
var d2 = $('#distance2').val();
console.log('Vr: ' + d1 + d2);
if(d1 != '' && d2 != '')
{
alert('vrednosti: ' +d1+' '+d2);
}
else
{
return false;
}
});
});
Not even initial alert() that says ‘hi!’ is not working. Anyone has clue?
As others have pointed out, you misspelled
function.Here’s a more up-to-date version of your code (jQuery 1.7+), just as an example: