Your snippet does not work because of this selector : var _test1 = _test.find('span.style');
When doing this, you try to find a span with the css class "style" not the html attribute style. And thus _test1 is empty.
You can do the following to fix it : var _test1 = _test.find('span[style]');
Though its not really a good selector, because it is most likely going to break if you change the css to remove it from inline.
You could add a class to the span <span class="aclass"></span>. And this way you can select it by the following selector : var _test1 = _test.find('span.aclass');
You could also select it in other ways like var _test1 = _test.find('span:nth-child(2)'); if it's always the second child.
These are only two of the multiple possible solutions to go with your _test2 and _test3
- You can also try to select all spans with inputs in it with
var _test1 = _test.find('span input'); or _test.find('span').children('input'). Then you can do your _test3.
Note that you can regroup the selector in 1 line :
This has the advantage of not having to put a class on the span since you actually not only query for the span but for a span WITH an input in it.
$('tr#idEstablishmentRow td.ms-formbody span input');
//or to get the id directly
$('tr#idEstablishmentRow td.ms-formbody span input').attr('id');