jquery

Jquery add click event for dynamically generated button

$( document ).ready(function() {
    $('body').on('click', '#export-btn', function(event) {
    
        //do stuff

    });
});

 

By bm on May 17, 2016 | jquery | A comment?

jquery get selected checkboxes values

var selected = "";
$('input[name=selected]:checked').each(function() {
    selected = selected +$(this).val()+",";
});
alert(selected);

 

By bm on | jquery | A comment?

jquery window close event

jQuery(window).bind(‘beforeunload’,function(e){
//save info somewhere
return ‘are you sure you want to leave?’;
});

jQuery(window).unload(function(){
//I will call my method

});

By bm on February 13, 2014 | jquery | A comment?

jquery geting object from html string

var elements = jQuery(‘<div><div>Live Customer Spport</div></div>’);

var found = jQuery(‘.head’, elements);
console.log(elements);
alert(elements.html());
alert(found.html());

By bm on | jquery | A comment?

regular expression validation example

var textval=$('data').val();
var regex =/^[A-Za-z0-9 ,]+$/;
if( !regex.test(textval) ) {
    alert('tex should not be empty or invalid character \nsupported character are A to Z, a to z, 0 to 9 , space and comma ( , ) ');
    return false;
}
By bm on | jquery | A comment?

jquery is checkbox checked

jQuery('#myfrom').on('click','.enable_upload',function(e) {

     if(jQuery(".enable_upload").is(':checked'))
          alert('checked');
     else
          alert('Not checked');

});
By bm on January 22, 2014 | jquery | A comment?