jQuery: wrap around substring...close, but not quite -


I am trying to select substrings - in character counting, in square brackets - in many paragraphs and each of them Wrap a class with & lt; Span & gt; In the tag, the "four way," applied here is HTML for one, and CSS:

   gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; P & gt; For more information about Pellentesque Hospice [100 character w / location] & lt; / P & gt; & Lt; A href = "/ give" & gt; Please & lt; / A & gt; & Lt; / Div & gt; & Lt ;! - end .featured_box - & gt;   

  span.char_count {padding-top: 0; Color: # FF 6600! Important; }   

Follow my Nob jQuery conformation:

  var select_p = $ ('div # promo_area div.featured_box p'); Select_p.each (function () {var first_index = $ (this) .html (). IndexOf ('[']; var last_index = $ (this) .html (). IndexOf (')') + 1; var selected_text = $ (This) .html (). Substrings (first_ index, final_index); selected_text.Wap ('& lt; span class = "char_count" />;);});) ???   

It seems that as long as the .wrap line works fine - I get the right subkey in selected_text . Wrap yourself does not work What small thing is I doing wrong? Or is this a stupid big thing?

My Bela is:

Thank you.

If you are feeling full, you can type categories and border brackets You can try to implement a solution using, or you can use the plugin to make it easier:

  $ (this). Highlight (selected_text, {element: 'span', className: 'char_count'});   

Here's a working child:

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -