1

My JSON response is something like this:

{
          "description": "discription about the feaure will come here.  <a href=\"http://example.com\" target=\"_blank\">Learn more</a>",
          "largeIconURL": "some_path/ico_someicon.gif",
          "displayName": "feature one"
        },
        {
          "description": "discription about the feaure will come here.",
          "largeIconURL": "some_path/ico_someicon.gif",
          "displayName": "feature two"
        },
        {
          "description": "discription about the feaure will come here. ",
          "largeIconURL": "some_path/ico_someicon.gif",
          "displayName": "feature three"
        },

My template is something like this

<%
        _.each(items,function(item, key, list){
      %>
      <li>
        <div class="oneSpec">

          <div class="description">
            <h4><%= item.displayName %></h4>
            <p><%= item.description %></p>
          </div>
        </div>
      </li>

      <%
        });
      %>

How can i remove the anchor tag from description node before painting it to the DOM

thefourtheye
  • 233,700
  • 52
  • 457
  • 497
debugging
  • 13
  • 4

2 Answers2

0

I'm not entirely sure what you mean by "from description", but you can conditionally include something by using <% if (condition) {%>. I'm just guessing what you mean. If this is not it, you have to be more clear...

Update:

Remove the anchor like so (Regex in Javascript to remove links):

<%=item.description.replace(/<a\b[^>]*>(.*?)<\/a>/i,"")) %>
Community
  • 1
  • 1
orange
  • 7,755
  • 14
  • 75
  • 139
0

One of the way is : After Rendering, Use


$(".description p a").remove(); //using jquery