I am trying to understand some jQuery syntax that I did not originally write.
<span id="mySpanElement" toggle-state="ON">Some Sample Text</span>
function switchOff(selectedControl) {
var fieldName = selectedControl.attr('toggle-state');
var newState = fieldName.replace("ON", "OFF");
return $("[toggle-state='" + newState + "']");
}
In this function does the return statement pass back a reference to an element in the DOM that has an attribute of toggle-state=OFF? I have never seen a selector based upon a custom attribute before and was unsure if I am understanding it correctly.
toggle-statematching whatever state it has been toggled to. Interesting concept...