• Hello,

    very fresh to WP – I m creating a custom widget.

    My goal is to have the widget display chained select lists in the admin.
    Select for choosing menu, select 2 will display menu items of that menu.

    But I am not able to make any jQuery work for the fields.
    I have added my js file, it loads fine and it actually runs any code that is not for the fields, e.g. :

    jQuery(document).ready(function(){
    alert('ok');

    will work…

    But :

    jQuery('#myelement').click(function(){
    		alert('Clicked');
    	})

    for an element inside the form like :
    <p id='myelement'> it won’t.

    There are no js errors in the console.
    I have looked everywhere, but found nothing so far… a few similar questions in forums etc do not have answers.

    What am I missing here? Any advises are much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter soupia18

    (@soupia18)

    ok – that’s so strange :
    if I attach jQuery based on class instead of elements’ id the code works…

    Thread Starter soupia18

    (@soupia18)

    i also just tried this:

    I made my jQuery id selector more specific, by adding the #widgets-right #myelement, so it selects the widgets from the sidebar’s side.

    This way it works.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘jQuery on Widget Admin Form Fields’ is closed to new replies.