Skip to content

Instantly share code, notes, and snippets.

@saintthor
Created February 21, 2017 16:33
Show Gist options
  • Save saintthor/47ba7c84271713bb630f1405718bf723 to your computer and use it in GitHub Desktop.
Save saintthor/47ba7c84271713bb630f1405718bf723 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/bacudi
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<style id="jsbin-css">
span { color: red }
</style>
</head>
<body>
<div contenteditable=true>wwww[A]oooo</div>
<button>color</button>
<script id="jsbin-javascript">
$( 'button' ).click( function()
{
var html = $( 'div' ).text();
$( 'div' ).html( html.replace( /\[A\]/g, '<span>[A]</span>'));
});
</script>
<script id="jsbin-source-css" type="text/css">span { color: red }</script>
<script id="jsbin-source-javascript" type="text/javascript">
$( 'button' ).click( function()
{
var html = $( 'div' ).text();
$( 'div' ).html( html.replace( /\[A\]/g, '<span>[A]</span>'));
});</script></body>
</html>
span { color: red }
$( 'button' ).click( function()
{
var html = $( 'div' ).text();
$( 'div' ).html( html.replace( /\[A\]/g, '<span>[A]</span>'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment