jQuery html attribute not working in IE

前端 未结 24 2549
[愿得一人]
[愿得一人] 2020-12-01 14:32

I am using country and state dropdowns in my form. Whenever the user selects the country in the dropdown, the respective states of the country will populate in the states dr

相关标签:
24条回答
  • 2020-12-01 15:00

    I have encountered an same problem when html does not work in IE.

    I believe it does not work if you have invalid html

    Example:

    For my case i am using an div without a close tag. So invalid html might be a culprit for IE

    0 讨论(0)
  • 2020-12-01 15:00

    In my case, I've had to change the selector that was a <figure> tag. This is what I had:

    HTML:

    <figure id="imagen">...</figure>
    

    JS (does not work):

    $("#imagen").html(res);
    

    And I had to replace with:

    HTML:

    <div id="imagen">...</div>
    

    JS (it works!):

    $("#imagen").html(res);
    
    0 讨论(0)
  • 2020-12-01 15:01

    add to .ajax options

    cache: false,

    0 讨论(0)
  • 2020-12-01 15:01

    The following method solved the problem for me:

    $('Element ID OR Class').empty().html(string);
    

    First use empty() & then set html using html()

    0 讨论(0)
  • 2020-12-01 15:02

    For me, I could only get it to work by placing my select in a placeholder div, and then write via .html(); the whole statement to that div. Works completely.

    0 讨论(0)
  • 2020-12-01 15:07

    Try using append instead of the html method as detailed in this post.

    edit

    Actually, I've just run into this problem myself. For me the answer was to call empty first, then append which has the same effect (I think?) as using the html method.

    0 讨论(0)
提交回复
热议问题