Академический Документы
Профессиональный Документы
Культура Документы
php
class sample
{
function show() // methods
{
echo "hello";
}
function add($x,$y)
{
return $x+$y;
}
}
echo $s->add(10,2);
?>
------------------------------------------------------------
<html>
<head>
<title>Dynamic add element</title>
<script>
function check()
{
var div=document.createElement("div");
div.innerHTML="hello friend";
document.body.appendChild(div);
}
</script>
</head>
<body>
</body>
</html>
-------------------------------------------
<html>
<head>
<title>Dynamic add element</title>
<script>
function check()
{
var div=document.createElement("div");
div.innerHTML="This is a div ";
var btn=document.createElement("button");
btn.innerHTML="Click Here";
document.getElementById("p1").appendChild(div);
document.getElementById("p1").appendChild(btn);
}
</script>
</head>
<body>
-------------------------------------------
<!-- attributes in javascript -->
<!-- these attribute check the existency of a attribute -->
<!-- attributes are
-->
<html>
<head>
<title>My Attribute</title>
<script>
function chkhas()
{
alert(document.getElementById("ins").hasAttribute("value"));
var x=document.getElementById("p1").hasAttribute("style");
if(x==false)
{
document.getElementById("p1").setAttribute("style","color:red");
}
}
function chkremove()
{
document.getElementById("email").removeAttribute("style");
}
function chkget()
{
let
x=document.getElementById("email").getAttribute("value");
alert(x);
if(x=="a@gmail.com")
{
document.getElementById("email").value="ankush@gmail.com";
}
}
function chkset()
{
document.getElementById("p1").setAttribute("style","border:2px solid
red;color:blue;font-size:32px;");
}
</script>
</head>
<body>
<p id="p1">Hello Friends</p>
let res=num1+num2;
alert("sum is "+res);
</script>
--------------------------------------
<!--
window methods
if(x==true)
{
alert("click on ok button");
}
else
{
alert("click on cancel button");
}
</script>
---------------------------------------
<!--
date() :- date is a object method.
:- to hold date and time.
:- date (day,month,year)
:- time(hour,minute,seconds)
d-m-y
dd-mm-yy
d-m-yyyy
yyyy-mm-dd
-->
<script>
alert(x);
alert(y);
alert(z.getMinutes());
alert(z.getHours());
alert(z.getSeconds());
alert(z.getDay());
alert(z.getMonth());
alert(z.getYear());
z.setHours();
z.setMinutes();
z.setSeonds();
z.setDay();
z.setMonth();
z.setYear();
</script>