Class: Svelte

Svelte

new Svelte()

Source:

Methods

<static> addClass(className)

Adds a class to the selector
Parameters:
Name Type Description
className string Name of class to add
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte
Example
$('.get-attr').attr('data-attr');
$('.set-attr').attr('data-attr','Value');

<static> blur()

Removes keyboard focus from first selector
Source:
Returns:
Svelte
Example
$('.blur').blur();

<static> children()

Find the children of the selector
Source:
Returns:
Svelte
Example
$('.selector').children();

<static> clone()

Clone a selector
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte
Example
$('.color').css('color', 'red');

<static> each(callback)

Each loop
Parameters:
Name Type Description
callback function Function to be run on each selector
Source:
Returns:
Svelte
Example
$('.each').each(function() { });

<static> empty()

Empty the HTML of a selector
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte
Example
$('.parent').find('.child');

<static> first()

Find the first element of the selector
Source:
Returns:
Svelte
Example
$('.selector').first();

<static> focus()

Sets the first selector to be focussed
Source:
Returns:
Svelte
Example
$('.focus').focus();

<static> hasClass()

Checks whether the selector has a specific class
Source:
Returns:
Boolean
Example
$('.class').hasClass('another-class');

<static> height()

Get the height of the first element in the selector
Source:
Returns:
number height
Example
$('.height').height();

<static> hide()

Sets selector to display none
Source:
Returns:
Svelte
Example
$('.hide').hide();

<static> html(html)

Set the HTML of a selector
Parameters:
Name Type Description
html string HTML to set
Source:
Returns:
Svelte or HTML
Example
$('.text').html('A span.');

<static> last()

Find the last element of the selector
Source:
Returns:
Svelte
Example
$('.selector').last();

<static> length()

Get the number of matched elements in the selector
Source:
Returns:
length
Example
$('.length').length();

<static> matches(selector)

Returns true if the element matches the selector string
Parameters:
Name Type Description
selector string Selector to match
Source:
Returns:
boolean
Example
$('.paragraph').matches('p');

<static> next()

Find the next sibling to the current selector
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte or HTML
Example
$('.text').outerHTML('A span.');

<static> parent()

Find the parent of the selector
Source:
Returns:
Svelte
Example
$('.selector').parent();

<static> position()

Returns the position of the first element in the selector relative to the viewport
Source:
Returns:
TextRectangle object
Example
$('.position').position();

<static> prev()

Find the previous sibling to the current selector
Source:
Returns:
Svelte
Example
$('.selector').prev();

<static> remove()

Removes a selector
Source:
Returns:
Svelte
Example
$('.remove-me').remove();

<static> removeAttr(name)

Remove an attribute from a selector
Parameters:
Name Type Description
name string Attr to remove
Source:
Returns:
Svelte
Example
$('.attr').removeAttr('data-attr');

<static> removeClass(className)

Removes a class from the selector
Parameters:
Name Type Description
className string Name of class to remove
Source:
Returns:
Svelte
Example
$('.class remove-class').removeClass('remove-class');

<static> show()

Sets selector to display block
Source:
Returns:
Svelte
Example
$('.show').show();

<static> text(text)

Set the text of a selector
Parameters:
Name Type Description
text string Text to set
Source:
Returns:
Svelte or text
Example
$('.text').text('Some text.');

<static> toggle()

Toggles the display property of the selector
Source:
Returns:
Boolean
Example
$('.visible').visible();

<static> toggleClass(className)

Toggles a class from the selector
Parameters:
Name Type Description
className string Name of class to toggle
Source:
Returns:
Svelte
Example
$('.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
Source:
Returns:
Svelte
Example
$('.click-me').trigger('click');

<static> val(value)

Get the value of a selector
Parameters:
Name Type Description
value string Value to set
Source:
Returns:
value
Example
$('.input').val();

<static> visible()

Checks whether the selector is visible
Source:
Returns:
Boolean
Example
$('.visible').visible();

<static> width()

Get the width of the first element in the selector
Source:
Returns:
number width
Example
$('.width').width();