jQuery(“#element-id”).removeClass(“class-name”);
Category Archives: jQuery
Add a class to element jquery
jQuery(“#element-id”).addClass(“class-name”);
Get the id of the element clicked jquery
<script>
$(“body”).click(function(event) {
alert(event.target.id)
});
</script>
Assign value to a textbox jQuery
jQuery(‘#text-box-id’).val(100);
Get the value of a text box jquery
jQuery(‘#text-box-id’).val();
Set the height of a div jquery
jQuery(‘#div-id’).height(100);
get the height of a div jquery
jQuery(‘#div-id’).height();
jquery get the height of the div
alert(jQuery(‘.div-class’).height());
jQuery replace a string
<html>
<head>
<script type=”text/javascript” src=”jquery.js”></script>
</head>
<div id=”divId”>
<iframe src=”http://phpcodez.com” scrolling=”no” frameborder=”0″ style=”border: none; width: 90px; height: 20px; “></iframe>
</div>
<script type=”text/javascript”>
jQuery.noConflict();
jQuery(document).ready(function() {
if(jQuery(“#divId”+” iframe”).attr(‘src’).indexOf(“https”)<=-1) {
var newSrc = jQuery(“#divId”+” iframe”).attr(‘src’).replace(“http”,”https”);
jQuery(“#divId”+” iframe”).attr(‘src’,newSrc);
alert(jQuery(“#divId”+” iframe”).attr(‘src’));
}
});
</script>
</html>
jQuery check if string contains another string
<html>
<head>
<script type=”text/javascript” src=”jquery.js”></script>
</head>
<div id=”divId”>
<iframe src=”http://phpcodez.com” scrolling=”no” frameborder=”0″ style=”border: none; width: 90px; height: 20px; “></iframe>
</div>
<script type=”text/javascript”>
jQuery.noConflict();
jQuery(document).ready(function() {
if(jQuery(“#divId”+” iframe”).attr(‘src’).indexOf(“https”)<=-1) {
alert(“Its not a secure url”);
}
});
</script>
</html>