JQuery.html () does not display data in ie7, but ie8 works

So who has no problems with ie7?

I can't seem to get ie7 to recognize some data.

I created a wordpress theme for my client, and this allows them to add additional information in wordpress meta fieldsthrough the administrator so that they can display additional information.

I wrote a small jQuery script that looks at images altand titleto collect this information and write it in a div.

Below is my script.

<script type="text/javascript">
    //<![CDATA[
    jQuery(document).ready(function(){
      var title = jQuery('.attachment-post-thumbnail').attr('title');
      var alt = jQuery('.attachment-post-thumbnail').attr('alt');
      jQuery('#vehicle-alt').html('<h2 class="car-detail">'+title+'</h2><p>'+alt+'</p>');
    });
    //]]>
</script>

When I look at the source code in ie7, the information is not transmitted.

div is as simple as <div id="vehicle-alt"></div>

+5
source share
3

.html() innerHTML. DOM, HTML-.

, jQuery html() empty() DOM. empty() html() div append().

 $('#vehicle-alt').append('html content');

mammods , JQuery.

+3

.

html, .

jquery: html, append, appendTo... .

html close. , .

+2

I had this error when there were two or more elements with the same identifier. This only happened in IE7.

The fix was, of course, to make sure each item has a unique identifier.

0
source

All Articles