Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts
0

Remove HTML tags in a string using javascript

Hi, following code depicts how a string with HTML tags, is converted to a string without any tags.


<HTML> 
<HEAD> 
<TITLE> Remove HTML tags </TITLE> 
</HEAD> 
<BODY onload="demo();"> 
<SCRIPT LANGUAGE="JavaScript"> 
function demo()
{


var orignal= '<p align="Left"><b>I</b> <I>Rock!</I></p>'; 
var modified = orignal.replace(/(<([^>]+)>)/ig,""); 


alert(orignal);
alert(modified);



</SCRIPT> 
</BODY> 
</HTML>


Keeps Coding! :)
0

Check whether a HTML control exists or not


<!DOCTYPE html>
<html> 
<head> 
   <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
   <title>Check whether a control exists</title> 
</head> 
<body> 
   <script type="text/javascript">
       function check() {
           if (document.getElementById('btn_yasser')) {
               alert('Exists !');
           }
           else {
               alert('Not present');
           }
       }
   </script> 
   <input type="button" id="btn_yasser" value="click me" onClick="check();" /> 
</body> 
</html>
The same could be used for ASP controls.
Hope this helps.
 

2011 ·Code-Studio by yrus.