1

Here is the working example:

http://jsfiddle.net/iorgu/szs90ykr/

The problem is that it's not working when I add ".productrating-param" to img like this:

$('.productrating-param img').after(mylayer.text());

What am I doing wrong?

var mylayer=$('.label-count').clone();

$('.productrating-param img').after(mylayer.text());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="label-count">7</div>
    <td class="param-value productrating-param">
        <img src="http://www.lamianaturashop.com/custom/kencekonyha/catalog/view/theme/rome_cappuccino/image/stars_5.png" alt="5 / 5 csillag!" >
    </td>

2
  • 1
    td-element cannot be the child of div-element. Commented Feb 10, 2017 at 12:38
  • @Esko Thank you! I cut the code out of the site that has it in the proper/normal usage. I should have been more attentive! Commented Feb 10, 2017 at 12:52

2 Answers 2

1

First of all you are using td tag... it should be wrapped in table tag to make it work.. Or dont use td tag.. below is the solution using table.. but i will request you if your structre does not need any table then use div instead..

var mylayer=$('.label-count').clone();

$('.productrating-param img').after(mylayer.text());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="label-count">7</div>
<table>
    <td class="param-value productrating-param">
        <img src="http://www.lamianaturashop.com/custom/kencekonyha/catalog/view/theme/rome_cappuccino/image/stars_5.png" alt="5 / 5 csillag!" >
    </td>
  </table>

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! This was because I cut it out of the site I'm testing the function to work.
NIce if this helped you, have a nice day
0

Your code can work, but you can not "test" with using only the tag <td> , you have to add the <table><tr> tags.

see here it is working

<table>
<tr>
<td class="param-value productrating-param" itemprop="aggregateRating" itemscope="" itemtype="//schema.org/AggregateRating">

<div class="label-count">7</div>
<img src="http://www.lamianaturashop.com/custom/kencekonyha/catalog/view/theme/rome_cappuccino/image/stars_5.png" alt="5 / 5 csillag!" style="margin-top: 2px;">
<div id="new"></div>

</td>
 </tr></table>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.