Check out the LIVE DEMO for filter() function
Encountering an issue where JQuery's find() method is not effectively working with HTML strings. It appears that injecting it into the DOM first is necessary in order for it to function correctly.
A demonstration on how well it performs with the filter()
method can be found here: Find element at HTML string
var header='<th id="tblHeader_1" style="width:80px;"><span>Id</span></th><th class="headerSortDown" id="tblHeader_2" style="width: 100px;"><span>Title</span></th><th class="headerSortDown" id="tblHeader_3" style="width:100px;"><span>Adress</span></th>';
var $header = $(header);
var th = $header.filter("th:last");
th.css('width',th.width() + 50 + 'px');
$header.appendTo('#main');
An alternative approach using the find()
method.
Experience another LIVE DEMO here
var header='<th id="tblHeader_1" style="width:80px;"><span>Id</span></th><th class="headerSortDown" id="tblHeader_2" style="width: 100px;"><span>Title</span></th><th class="headerSortDown" id="tblHeader_3" style="width:100px;"><span>Adress</span></th>';
var currentwidth = 100;
$('#main').append(header).find('th:last').css('background-color','red');//For Testing pu
//Increase last th width
$('#main').find('th:last').css('width',currentwidth + 50 + 'px');
Take a look at this discussion about using JQuery to search within an HTML string