I have this code which not give me desired result
I want output as same
http://www.asteraweb.co.uk/wrap_example.html
same as like first container have
I have this code but its working on no. of word and missing some words in the last
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>wrapped</title>
<script type="text/javascript" language="javascript">
function set_padd(){
var tt = document.getElementById("span_padding").innerHTML;
var txt = new Array();
txt = tt.split(" ");
var atxt = '';
var f_txt = '';
var wrd_pr_linr = 4;
var cnt = 1;
for(var i = 0; i < txt.length; i++){
if(txt[i].length > 0){
txt[i] = txt[i].replace('','');
if(cnt < wrd_pr_linr){
if(txt[i].length > 0){
atxt += ' '+txt[i].replace('','');
cnt++;
}
}else{
f_txt += '<a class="padd_txt" ><strong>'+atxt+'</a></strong><br />';
atxt = '';
cnt = 1;
}
}
}
document.getElementById("span_padding").innerHTML = f_txt;
}
</script>
<style type="text/css">
.padd_txt{padding:7px;background:#009;color:#FFF;line-height:26px;font-size:14px;}
body{font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:24px; line-height:1.2em;}
span{background-color: #009; width:200px; color: #FFF;"}
</style>
</head>
<body onload="set_padd();">
<div style="width: 350px;">
<p>
<span id="span_padding">
This is what I want to
happen where one
long string is wrapped
and the text has this
highlight color behind it.
behind me.
</span>
</div>
</body>
</html>
out put is:
This is
I want to
happen where one
string is wrapped
and the text
this highlight
behind it. behind
this missing one last word "me " on firefox and two last word "behind me" on IE
this may be a java script problem or css problem
plz help me to short out this problem
Thanx