JSFiddle - React, Tailwind, and code Playground

HTML

<p id="a">A</p>
<p id="b">B</p>
<p id="c">C</p>

JavaScript

$.fn.myPlugin = function(related) {
    if ( related == "getRelated" )
        return $(this.data("related")); // Want to preserve stack
    return this.data("related",related);
};

$("#a")
    .next().css("color","red")
    .end().css("color","blue"); // Should set color of "a" to blue - works

$("#a").myPlugin( $('#c') );

$("#a").myPlugin("getRelated")
    .css("color","green")
    .css("color","yellow"); // Should set color of "a" to yellow - don't work