Skip to main content

Get parent element in jQuery

We often need access of parent elements in the DOM while using jQuery functions.This can be achieved by using element.parent().

Let us take some example:

HTML Code:
<div id="div1">
        <span>This is span</span>
</div>

jQuery Code:
<script>
$($document).ready(function(){
    var par_id = ("span").parent().attr('id');
    alert(par_id);
});
</script>

Comments

Popular posts from this blog

MYSQL CONNECTION USING PDO WITH PHP

Hello guys, In the previous tutorial we have seen how to connect to MySQL database with PHP using MySQLi. Today we will learn how to connect with PDO. As a PHP programmer we have learned how to access database by using either MySQL and MySQLi. As of PHP 5.1, there's a better way. PHP Data Objects(PDO) provide methods for prepared statements and working with objects that will make you far more productive! PDO Introduction :        PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. Database Support:       The extension can support any database that a PDO driver has been written for. The following drivers currently implement the PDO interface: PDO_CUBRID Cubrid PDO_DBLIB FreeTDS / Microsoft SQL Server / Sybase PDO_FIREBIRD Firebird PDO_I...

Convert HTML to PDF using mPDF library

PDF is format of file to share .Here is code for converting html to PDF using mpdf library (PHP library). //include library path include('mpdf/mpdf.php'); $mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0); $mpdf->SetDisplayMode('fullpage'); $mpdf->list_indent_first_level = 0; $mpdf->WriteHTML('<html><head></head><body><h2>Welecome to HTML to PDF </h2></body></html>'); //save the file put which location you need folder/filename $mpdf->Output('test.pdf', 'F'); You can download the library from GitHub. Extract it and paste into your (project folder).

Basic Linux commands

Linux has a basic impact in our life. However, getting started with Linux just make you discomfort for the first time. Because on Linux, you usually should use terminal commands instead of just clicking the launcher icon (as you did on Windows).But don't worry with experience of more than 3 years as a Developer i feel  Linux is best as using it.We will give you the mostly used linux commands. So let's get started with the list of 10 Linux Basic commands - 1. sudo ("superuser do") - Allows you to run other commands with administrative privileges. This is useful when, for example, you need to modify files in a directory that your user wouldn't normally have access to. $ sudo su 2.   ls ("list") - Lists all files and folders in your current working directory. You can also specify paths to other directories if you want to view their contents. /home$ ls 3. cd ("change directory") - Changes the directory you are currently working in. You can use ...