Showing posts with label jQuery. Show all posts
How to Add Active Navigation Class Based on URL?
Ideally you output this class from the server side, but if you can't...
Let's say you have navigation like this:
HTML:
<nav>
<ul>
<li><a href="/">Home</a></li>
.
jQuery to load first 5 elements & click "load more" to display next 5 elements
jQuery functionality to load first 5 elements & click "load more" to display next 5 elements.
HTML:
<ul id="myList">
<li>One</li>
<li>Two</li>
<li>Three</li>
.
How to get the class name using jQuery?
Consider the following HTML:
<div id="myId" class="myclass"></div>
jQuery:
var className = $('.myclass').attr('class');
(or)
var className = $('#myId').attr('class');
Reference: StackOverflow.c.
Working with jQuery ajax error function
By using the $.ajaxSetup() we can handle the error/exception as mentioned below:
$(function() {
$.ajaxSetup({
error: function(jqXHR, exception) {
.
Working with Dynamic Pagination in ASP.NET
Pagination is a typical process in data display whereby large sets of data are broken into discrete sections for viewing, more often than not used in conjunction with some type of grid or list component.
CSHTML:
@using Smp.Web.Common;
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
.
Working with Cookies in ASP.NET
Usage of Cookies in ASP.NET using C# or jQuery. A cookie is a piece of data which is sent from a website and stored locally by the user’s browser. Cookies are needed because HTTP is stateless. This means that HTTP itself has no way to keep track of.
Working with Session in ASP.NET
Usage of Session in ASP.NET using C# or jQuery. A session is a piece of data which is sent from a website and stored locally by the user’s browser. Sessions are needed because HTTP is stateless. This means that HTTP itself has no way to keep track of.
How to upload file using jQuery/Ajax?
The following AJAX File Upload jQuery Tutorial covers how to upload files asynchronously using jQuery Framework.
Generic Handler: AjaxFileUploader.ashx
public class AjaxFileUploader : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
.
How to Remove the white spaces at the start and end of the string?
The $.trim() function removes all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of the supplied string. If these whitespace characters occur in the middle of the string, they are preserved.
<!doctype html>
<html.
How to get the value of a CSS property using jQuery?
Consider the following HTML:
<div id="jjTechSol" style="height: 50px;width: 50px;">
<p>Content</p>
</div>
The following jQuery is used to get the value of a CSS property.
<script type="text/javascript">
$(document).ready(function.
How to Compare two fields with jQuery validate plugin?
Consider the following HTML.
<input type="text" id="txtEmail" name="Email" />
<input type="text" id="txtConfirmEmail" name="ConfirmEmail" />
The following script is used to Compare two fields with jQuery validate plugin.
$('#myform').validate({
.
How to hide the first option of a select using jQuery
When using "jquery.selectbox.js" plugin the "select & option" tags will be converted into "ul li" at run time. In this case it's hard to hide the first option using the normal select option script. The following solution rectifies this situation..
How to get current HTML Page Title/URL with jQuery/Javascript?
Get current HTML page Title and URL with jQuery and Javascript.
Current Page Title:
jQuery:
var title = $(document).find("title").text();
(or)
var title = $('title').text();
(or)
var title = $(document).attr('title');
Javascript:
var title.
How to call a WebMethod of a Web Service using jQuery Ajax JSON?
How to call a WebMethod of a Web Service using jQuery Ajax JSON
The following jQuery is used to call a WebMethod of a Web Service using jQuery Ajax JSON.
jQuery:
$(document).ready(function () {
var Name = $("#name").val();
var Email = $("#email").val();
var.
How to find the value of a HTML tag attribute using jQuery?
Note:
When using "jquery.selectbox.js" plugin the "select & option" tags will be converted into "ul li" at run time. The problem is we can not get the selected value using the normal jQuery or Javascript when we use this plugin. The following.
How to find the first parent element in jQuery?
To find the first parent element using jQuery.
HTML:
<div class="container1">
<div class="container2">
<div class="container3">
<div.
How to check 'undefined' value in jQuery?
One option is to use typeof operator:
if (typeof val === "undefined") {
// ...
}
It returns a string indicating the type of the variable or other
unevaluated operand. The main advantage of this method is that it will
never raise an.