I have created the funtion below, It search the body for a specific Word, and im able to get the result if it exist or not. But If it exist, how do i then find that specific Object and interract with it.?
(function ($) {
$.fn.WordBreaker = function (x) {
return this.each(function () {
var wrapper = $(this);
var xx = $.extend({
words: "",
}, x || {});
function initialized() {
xx.words.forEach(function (x, y) {
var lw, rw;
lw = x.toString().split(",")[0];
rw = x.toString().split(",")[1];
if ($("body:contains('" + lw + "')").length > 0) {
alert("I found an object that contains: " + lw + " , but how do i tager that object?")
}
}, xx.words)
}
initialized();
});
}
}(jQuery));
var items = [
["THISISALONGTEXTTHATIWANTTOBREAK", "THIS-IS-A-LONG-TEXT-THAT-I-WANT-TO-BREAK"]
];
$('.col-md-5').WordBreaker({ words: items })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<div class="col-md-5" style="background: #00ffff">
<h1>THISISALONGTEXTTHATIWANTTOBREAK</h1>
</div>
</div>
. – Seb Dec 06 '16 at 14:27