Methods
-
<static> addClass(className)
-
Adds a class to the selector
Parameters:
Name Type Description className
string Name of class to add Returns:
SvelteExample
$('.class').addClass('another-class');
-
<static> append(position, html)
-
Add HTML to the page in relation to the current selector
Parameters:
Name Type Description position
string The position to add the html - before, after, atstart, atend html
string The HTML to add Returns:
SvelteExample
$('.html').append('before','
I am before
'); -
<static> attr(name, value)
-
Get or set the attribute of a selector
Parameters:
Name Type Description name
string Attr to get or set value
string Value to set Returns:
SvelteExample
$('.get-attr').attr('data-attr'); $('.set-attr').attr('data-attr','Value');
-
<static> blur()
-
Removes keyboard focus from first selector
Returns:
SvelteExample
$('.blur').blur();
-
<static> children()
-
Find the children of the selector
Returns:
SvelteExample
$('.selector').children();
-
<static> clone()
-
Clone a selector
Returns:
SvelteExample
$('.empty-me').clone();
-
<static> css(property, value)
-
Set the CSS for an element
Parameters:
Name Type Description property
string Property of element to set value
string Value of property to set Returns:
SvelteExample
$('.color').css('color', 'red');
-
<static> each(callback)
-
Each loop
Parameters:
Name Type Description callback
function Function to be run on each selector Returns:
SvelteExample
$('.each').each(function() { });
-
<static> empty()
-
Empty the HTML of a selector
Returns:
SvelteExample
$('.empty-me').empty();
-
<static> find(selector)
-
Find a new selector within a parent selector
Parameters:
Name Type Description selector
string Find a new selector within a parent selector Returns:
SvelteExample
$('.parent').find('.child');
-
<static> first()
-
Find the first element of the selector
Returns:
SvelteExample
$('.selector').first();
-
<static> focus()
-
Sets the first selector to be focussed
Returns:
SvelteExample
$('.focus').focus();
-
<static> hasClass()
-
Checks whether the selector has a specific class
Returns:
BooleanExample
$('.class').hasClass('another-class');
-
<static> height()
-
Get the height of the first element in the selector
Returns:
number heightExample
$('.height').height();
-
<static> hide()
-
Sets selector to display none
Returns:
SvelteExample
$('.hide').hide();
-
<static> html(html)
-
Set the HTML of a selector
Parameters:
Name Type Description html
string HTML to set Returns:
Svelte or HTMLExample
$('.text').html('A span.');
-
<static> last()
-
Find the last element of the selector
Returns:
SvelteExample
$('.selector').last();
-
<static> length()
-
Get the number of matched elements in the selector
Returns:
lengthExample
$('.length').length();
-
<static> matches(selector)
-
Returns true if the element matches the selector string
Parameters:
Name Type Description selector
string Selector to match Returns:
booleanExample
$('.paragraph').matches('p');
-
<static> next()
-
Find the next sibling to the current selector
Returns:
SvelteExample
$('.selector').next();
-
<static> off(name, callback)
-
Removes an event from the selector
Parameters:
Name Type Description name
string Name of event e.g. click or names of events separated by spaces e.g. 'keyup keydown' callback
function Callback to run when event is triggered Returns:
SvelteExample
$('.click-me').off('click', function() { alert('Clicked!'); });
-
<static> on(name, callback)
-
Attaches an event to the selector
Parameters:
Name Type Description name
string Name of event e.g. click or names of events separated by spaces e.g. 'keyup keydown' callback
function Callback to run when event is triggered Returns:
SvelteExample
$('.click-me').on('click', function() { alert('Clicked!'); });
-
<static> one(name, callback)
-
Attaches an event to the selector and removes after callback
Parameters:
Name Type Description name
string Name of event e.g. 'click' or names of events separated by spaces e.g. 'keyup keydown' callback
function Callback to run when event is triggered Returns:
SvelteExample
$('.click-me').one('click', function() { alert('Clicked!'); });
-
<static> outerHTML(html)
-
Set the outerHTML of a selector
Parameters:
Name Type Description html
string HTML to set Returns:
Svelte or HTMLExample
$('.text').outerHTML('A span.');
-
<static> parent()
-
Find the parent of the selector
Returns:
SvelteExample
$('.selector').parent();
-
<static> position()
-
Returns the position of the first element in the selector relative to the viewport
Returns:
TextRectangle objectExample
$('.position').position();
-
<static> prev()
-
Find the previous sibling to the current selector
Returns:
SvelteExample
$('.selector').prev();
-
<static> remove()
-
Removes a selector
Returns:
SvelteExample
$('.remove-me').remove();
-
<static> removeAttr(name)
-
Remove an attribute from a selector
Parameters:
Name Type Description name
string Attr to remove Returns:
SvelteExample
$('.attr').removeAttr('data-attr');
-
<static> removeClass(className)
-
Removes a class from the selector
Parameters:
Name Type Description className
string Name of class to remove Returns:
SvelteExample
$('.class remove-class').removeClass('remove-class');
-
<static> show()
-
Sets selector to display block
Returns:
SvelteExample
$('.show').show();
-
<static> text(text)
-
Set the text of a selector
Parameters:
Name Type Description text
string Text to set Returns:
Svelte or textExample
$('.text').text('Some text.');
-
<static> toggle()
-
Toggles the display property of the selector
Returns:
BooleanExample
$('.visible').visible();
-
<static> toggleClass(className)
-
Toggles a class from the selector
Parameters:
Name Type Description className
string Name of class to toggle Returns:
SvelteExample
$('.class toggle-class').toggleClass('toggle-class');
-
<static> trigger(name, detail)
-
Trigger an event from the selector
Parameters:
Name Type Description name
string Name of event e.g. click detail
object The data passed when initializing the event Returns:
SvelteExample
$('.click-me').trigger('click');
-
<static> val(value)
-
Get the value of a selector
Parameters:
Name Type Description value
string Value to set Returns:
valueExample
$('.input').val();
-
<static> visible()
-
Checks whether the selector is visible
Returns:
BooleanExample
$('.visible').visible();
-
<static> width()
-
Get the width of the first element in the selector
Returns:
number widthExample
$('.width').width();