Wrap each matching element in DIV
I am trying to wrap each matching elment in a DIV. I.E every time an element in Group A matches an elemnt in Group B, wrap them both in a DIV. With the help of JΛ̊KE I was able find the matches but I can't find a way to wrap them. How Can I achieve this please.
My code looks like below
- $(document).each(function() {
- var pMatch = $('.one li').map(function(){
- return $(this).text()
- })
- var sMatch = $('.two li').map(function() {
- return $(this).text()
- })
- $.each(pMatch,function(i,h) {
-
- if (h===sMatch[i])
-
- $('.show-here').text('This is Working');
-
- else
-
- $('.show-here').text('This is not Working');
- });
-
-
-
- });
Link to jsFiddle