• Resolved Andrew Nevins

    (@anevins)


    WCLDN 2018 Contributor | Volunteer support

    Hello,

    I want to clear the content in my HTML input fields, that have the class name ‘gllr_image_video_url’.

    The
    document.write()
    is only for testing.

    document.write(jQuery(this))
    Returns five objects of my input fields, but I can’t grab the values.

    When I do this
    document.write(jQuery(this).val())
    The document.write never gets executed.

    I’m just trying to set the value to nothing (below), if the value of the input is equal to that of a string, ‘Video URL’.

    // Gallery input url focus
    jQuery(document).ready(function() {
    var url_input = jQuery('input.gllr_image_video_url');
    	jQuery(url_input).each(function() {
    
    		jQuery(this).focus(function(){
    			document.write(jQuery(this).val());
    			if (jQuery(this.val()) == 'Video URL'){
    				jQuery(this.val()) = '';
    			}
    			else {
    				//
    			}
    
    		});
    
    	});
    });

    Any ideas why this isn’t happening?

  • The topic ‘jQuery val() Not Working’ is closed to new replies.