1

I'm still new in this area, have few questions.

I have JQuery from this site: http://goskylar.com/wp-content/demos/jquery.hyphenate/

It is solve my problem regarding hyphenation. However, when I put some html tag such as <strong> or <u> the result shows no effect. My question is:
Where and how should I add the function for css attribut so that it can shows the <strong> or <u> results?

--edited--

<script>
(function($){$.fn.hyphenate=function(options) {
   settings=$.extend({oWidth:this.width()},options);

return this.each(function(){
  $(this).css({
    'width':settings.oWidth,
    'display':'block'
  });
  var str='';
  $.each($(this).text().split(' '),function(i,chunk){str+=splitChunk(chunk)+' ';});
  $(this).html(str);    
});

function splitChunk(str){
  if($('<span></span>').text(str).hide().appendTo(document.body).width() > settings.oWidth)
  {var s=''; var i=0;
    while(i < str.length)
    {
      s+=(str.slice(i,++i)+'&shy;');
    }
    return s;
  }
  else
    return str;
    }
  };

})(jQuery);
</script>

<html>
<head>
<title>Hyphenation</title>
</head>
<body>

<script>
jQuery(document).ready(function(){
    $('#d4').hyphenate({oWidth:158});
});
</script>

<div id="d4">this will start with <u>spaces and this firstthisi<strong>sareallylongsentence</strong>withlotsots</u>andlotsofwords</div>
</body>
</html>

1 Answer 1

1

About #2, You want to add/change an attribute on an element? jQuery doc and example

More about jQuery Attributes

About #1, can you elaborate more? What query are you talking about?

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

1 Comment

Sorry, it's not query but actually jquery.hypheante.js itself.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.