I usually see this:
var markup = $(this).html(); $(this).html('<strong>whoo hoo</strong>');
I agree with Raminon. Your examples that you saw do not look right.
This code is usually displayed in a jquery loop, for example, each () or event handler. Inside the loop, the variable 'el' indicates a pure element, not a jQuery object. The same is true for 'this' inside the event handler.
When you see the following: $ (el) or $ (this), the author gets a jQuery reference to the dom object.
Here is an example that I used to convert numbers to Roman numbers: (Note, I always use jQuery instead of $ - there are too many collisions with mootools ...)
jQuery(document).ready(function(){ jQuery('.rom_num').each(function(idx,el){ var span = jQuery(el); span.html(toRoman(span.text())); }); });
Perry Tew Jul 16 2018-12-12T00: 00Z
source share