What I am trying to do is, check whether span with class ui-icon ui-icon-minusthick
exists or not, if it exists first remove it and then add it. I tried in following way, but it's not working
javascript function::
jQuery.fn.initPortlet = function( parent_component ,header , component ){
this.find(header).find('span.ui-icon').remove();
this.addClass("ui-widget ui-widget-content ui-corner-all")
.find(header)
.addClass("headertitle")
.addClass("align_center")
.addClass("defaultheadercolor")
.end()
.prepend('')
.find(component);
}
and I am calling this function in this way..
$('.div_portlet').initPortlet('.div_portlet','.div_header','.div_content')
It should first remove the span then add it, but if I am calling this function multiple times then it just keep on adding that span.
How can I do this or is there any better way to do this.
Thanks!!!!