Skip to content

Instantly share code, notes, and snippets.

@fedmich
Created April 21, 2012 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedmich/2440296 to your computer and use it in GitHub Desktop.
Save fedmich/2440296 to your computer and use it in GitHub Desktop.
Stack overflow answers
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var obj_h2 = $('h2');
var h2_title = obj_h2.html();
var words = h2_title.split(' ');
words[0] = '<span>' + words[0] + '</span>'
obj_h2.html( words.join( ' ' ) );
});
</script>
<style type="text/css">
h2 span{
color:red;
}
</style>
</head>
<body>
<h2>Converted post title</h2>
</body>
</html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('h2.title').each( function (){
var obj_h2 = $(this);
var h2_title = obj_h2.html();
var words = h2_title.split(' ');
words[0] = '<span>' + words[0] + '</span>'
obj_h2.html( words.join( ' ' ) );
} );
});
</script>
<style type="text/css">
h2.title span{
color:red;
}
</style>
</head>
<body>
<h2 class="title">Converted post title</h2>
<h2 class="title">Title #2</h2>
<h2 class="title">This is H3 #3</h2>
</body>
</html>
RedirectMatch 301 ^/(site1|site2|category1)(/.*|$) /$1-new$2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment