Reputation: 800
I have the following javascript code in a HTML document which loads Html in a div:
<script>
$(function(){
$("#submenu a").click(function(){
var page = this.hash.substr(1);
$.get(page+".html",function(gotHtml){
$("#contenedorprincipal").html(gotHtml);
})
});
});
</script>
In Firefox it runs perfectly, but in Chrome and IE it does not work. Any ideas or suggestions?
Upvotes: 2
Views: 565
Reputation: 185933
This should work across browsers:
$(function () {
var $content = $( '#contenedorprincipal' );
$( '#submenu' ).on( 'click', 'a', function ( e ) {
$content.load( this.href.split( '#' )[1] + '.html' );
});
});
Upvotes: 0
Reputation: 7881
seems to me like it works in chrome... any way try this: http://jsfiddle.net/8daxU/
replace the wrapping function with (I added an alert just to show the hash - remove at afterwords)
$(document).ready(function(){
$("#submenu a").click(function(){
var page = this.hash.substr(1);
alert(page);
$("#contenedorprincipal").load(page+".html");
});
});
Upvotes: 2