How to Determine if an Element Exists with jQuery?

jQuery makes it easy to determine if an element in your DOM exists.

if ( $('#elementID').length ) 
{
 // do something
}

Simple enough, right?

Clip to Evernote

2 notes / Permalink

Tags: jquery tips code

How to use jQuery to see if an element exists

To see if an element exists in jQuery you simply need to check for a length

$("#myElement").length

If the above ID has a length the statement returns true.

Tested in jQuery v1.4.2

Clip to Evernote

1 note / Permalink

Tags: jQuery code

How to do an Include in ASP.Net site

While doing some recent ASP.Net development I needed to use a Server Side Include (SSI) in a few pages of the site. Those familiar with ASP.Net might stop right here and say, “Just use the Master Page file.” Well the Master Page option wouldn’t work for the solution I needed.

I discovered that ASP.Net differs from ASP, PHP, or even SHTML in the fact that you can’t include a file with the traditional include statement: <!--#include file="include/file.txt" -->. So after a touch of research I uncovered the ASP.Net alternative to the “include” option.

<% Response.WriteFile(“files/name.txt”); %>

This method will write the file from the path in the rendered HTML of the page.  A handy little tool to keep in the repertoire.

Clip to Evernote

0 notes / Permalink

Tags: asp.net code