WordPress有默认的jQuery。因此,无需显式加载此文件。
JS代码:
jQuery(\'#toggle-onoff-network\').on({
\'click\': function () {
var origsrc = jQuery(this).attr(\'src\');
var src = \'\';
if (origsrc == \'img1_on.png\') src = \'img2_on.png\';
if (origsrc == \'img2_on.png\') src = \'img1_on.png\';
jQuery(this).attr(\'src\', src);
}
});
// The script
jQuery( "#netywork-toggle" ).click(function() {
jQuery( "#share-stuff" ).slideToggle( "slow", function() {
// Animation complete.
});
});
HTML代码:(删除了jQuery文件加载)
<div id="netywork-toggle"> <!--This is where I want it to appear-->
<img id ="toggle-onoff-network" src="img1_on.png" width="auto" height="34"/>
</div>
<div id="share-stuff">
<ul class="crafty-social-buttons-list">
<li><a href="#" target="_blank"><img title="Pulseframe Code" alt="Facebook" width="38" height="38" src="facebook.png"></a></li>
<li><a href="#" target="_blank"><img title="Pulseframe Geek" alt="twitter" width="38" height="38" src="facebook.png"></a></li>
<li><a href="#" target="_blank"><img title="Comming Soon" alt="Comming Soon" width="38" height="38" src="facebook.png"></a></li>
</ul>
</div>