JQuery junk code adding itself to HTML Content in SharePoint 2010
Not sure why its doing it to my content editor webpart but i have jquery installed and i have a menu that is clickable and hoverable. When clicked or hovered it changes the content in the div beside it in the same content editor web part. The content is changed by removing and adding different classes (one that hides and another that displays). The menu g开发者_如何学Goets all this nasty code attached to it after every usage. I'm thinking this could be really bad once the site is live. The junk added looks like this (after two uses):
<div id="heading-3" jquery1316195534303="3" jquery1316195730747="3">
It works just fine with it and without it. What is going on and what can i do about it? My code is pretty straight forward:
CSS
#rotatorBlocks .non-active {
display: none;
}
#rotatorBlocks .active {
display: block;
}
JQuery
$(function() {
var current;
function rotate() {
var currentSplit = current.split("-");
var num = currentSplit[currentSplit.length - 1];
$("#rotatorBlocks .active").removeClass("active").addClass("non-active");
$("#block-" + num).addClass("active");
}
var hoverOrClick = function () {
current = this.id.substr(6);
rotate();
}
$('#rotatorHeadings div').click(hoverOrClick).hover(hoverOrClick);
});
I don't have an answer, I just couldn't bear to look at all that conditional code:
var current;
function rotate() {
var currentSplit = current.split("-");
var num = currentSplit[currentSplit.length - 1];
$("#rotatorBlocks .active").removeClass("active").addClass("non-active");
$("#block-" + num).addClass("active");
}
精彩评论