11548 sujets

JavaScript, DOM et API Web HTML5

Bonjour,

pourquoi ce code ne fonctionne t-il pas sur IE mais fonctionne sur FF ?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<SCRIPT type="text/javascript" src="Panier_fichiers/jquery.min.js"></SCRIPT>
<SCRIPT type="text/javascript" src="Panier_fichiers/jquery-ui.min.js"></SCRIPT>
<SCRIPT type="text/javascript">
$(function() {
	$("#test").attr("onclick", "alert('hello world')");	
});
</SCRIPT>
</head>
<body>
<P id="test">click here</P>
</body>


Merci d'avances pour vos éclaircissements.

mathmax
Modifié par mathmax (10 May 2009 - 16:59)
Salut,

je ne sais pas trop mais :
* cela ne t'empêche pas d'écrire un code xhtml valide. Smiley cligne
* pourquoi ne pas utiliser click ?
* à priori UI est inutile pour faire cela.

Cela pourrait donner :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<script type="text/javascript" src="include/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function() {
    $("#test").click(function () {
	alert('hello world');
    });
});
</script>
</head>
<body>
<p id="test">click here</p>
</body>
</html>
a écrit :
pourquoi ne pas utiliser click ?


oui, mais si je veux m'abonner à l'événement "onchange" d'une liste déroulante ?