• Hi,

    I want to add or remove options from a select dropdown using jquery, but I can’t get it to work, jquery isn’t working at all.

    Here is my code

    add_shortcode( 'filters_user_owns', function () {
    	
    	
    	global $current_user;
    get_currentuserinfo();
    	
    	if($current_user->filter_type_1)
    	{
    		
    		?>
    
    	<script>
    $("#addon-19-filter-choice-0").append('<option value="filter1">Filter 1</option>');</script>
    		<?php
    		
    	}
    
    } );
Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    It’s probably worth ensuring that jQuery is enqueued:

    add_action( 'wp_enqueue_script', function () {
    
    	wp_enqueue_script( 'jquery' );
    
    } );

    And I’m not sure if WordPress still uses jQuery in noConflict mode, but it’s also worth trying the full jQuery function instead of $:

    jQuery("#addon-19-filter-choice-0").append('<option value="filter1">Filter 1</option>');</script>

Viewing 1 replies (of 1 total)
  • The topic ‘Jquery to append options onto a dropdown’ is closed to new replies.