I have the below jQuery code that I copied from another site and need to modify it to work with my setup.
The code currently (I think anyways) won't work if I copy and paste the function and just change the html id element identifier.
How can I duplicate this code chunk and make it unique so they don't conflict with each other?
jQuery(document).ready(function() {
jQuery('#upload_image_button').click(function() {
formfield = jQuery('#hccfavicon').attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery('img',html).attr('src');
jQuery('#hccfavicon').val(imgurl);
tb_remove();
}
});
You see #hccfavicon. That's the item I'd be swapping for the various instances where I need to use this jQuery fu开发者_Python百科nction.
精彩评论