当前位置: 动力学知识库 > 问答 > 编程问答 >

html - Search first character of paragraph. If found, replace entire paragraph with bold

问题描述:

I need a command that will search for # sign in the first position of every paragraph in an rtf document. If the # sign is found, I would like to be able to make the entire paragraph bold.

网友答案:

Easy to do with query.

JQUERY

$('p').each(function(){     
  if($(this).text().substr(0,1) == '#'){
     $(this).addClass('bold')
  }
})

CSS

.bold {
    font-weight:bold;
}

Here is the Fiddle: http://jsfiddle.net/2wcqW/3/

分享给朋友:
您可能感兴趣的文章:
随机阅读: