jQuery.fn.toggleText = function (v1, v2) {
return this.each(function () {
var element = $(this),
text = element.text()
if (text.indexOf(value1) > -1) {
element.text(text.replace(v1, v2))
} else {
element.text(text.replace(v2, v1))
}
})
}
// When this is called, all instances of Yes are replaced with No and vice-versa
$('p').toggleText('Yes', 'No')