11548 sujets

JavaScript, DOM et API Web HTML5

Bonjour à tous,

Je suis nouveau sur le forum et suis novice dans la programmation Smiley lol . Malgré tout j'essai de faire quelque chose de propre au maximum et là.. je rencontre un problème auquel je ne trouve pas de solution (c'est sûrement très bête en plus :s).

	<script type="text/javascript">  
  
$(document).ready(function() {  
  
    //Select all anchor tag with rel set to tooltip  
    $('a[rel=tooltip]').mouseover(function(e) {  
          
        //Grab the title attribute's value and assign it to a variable  
        var tip = $(this).attr('title');      
          
        //Remove the title attribute's to avoid the native tooltip from the browser  
        $(this).attr('title','');  
          
        //Append the tooltip template and its value  
        $(this).append('<div id="tooltip"><div class="tipHeader" /><div class="tipBody">' + tip + '</div><div class="tipFooter" /></div>');       
          
        //Set the X and Y axis of the tooltip  
        $('#tooltip').css('top', e.pageY + 10 );  
        $('#tooltip').css('left', e.pageX + 20 );  
          
        //Show the tooltip with faceIn effect  
        $('#tooltip').fadeIn('500');  
        $('#tooltip').fadeTo('10',0.8);  
          
    }).mousemove(function(e) {  
      
        //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse  
        $('#tooltip').css('top', e.pageY + -60 );  
        $('#tooltip').css('left', e.pageX + -25 );  
          
    }).mouseout(function() {  
      
        //Put back the title attribute's value  
        $(this).attr('title',$('.tipBody').html());  
      
        //Remove the appended tooltip template  
        $(this).children('div#tooltip').remove();  
          
    });  
  
});  
  
</script>


Voici donc mon script et l'erreur que me rapporte le W3C :

a écrit :
Line 23, Column 42: document type does not allow element "div" here
… $(this).append('<div id="tooltip"><div class="tipHeader" /><div class="ti…



D'avance merci,
Modifié par Kasoa (04 Apr 2010 - 15:54)
Mon dieu, avec un CDATA c'est tellement plus mieux :<

Dommage que je ne puisse effacer mon post.. si quelqu'un peut le faire.. Smiley lol
Kasoa a écrit :
Dommage que je ne puisse effacer mon post.. si quelqu'un peut le faire.. Smiley lol


Pourquoi? Ça peut servir à d'autres… Smiley cligne
paolo a écrit :
Et avec un script externe, c'est encore plus mieux Smiley cligne


Dans un .js ?

Patidou a écrit :


Pourquoi? Ça peut servir à d'autres… Smiley cligne


C'est pas faux ^^