Append id to URI - how to?

Daiaiai

I do some jquery-toggle-action to an element and want to append a static id to the URL while it. So this is what I am doing:

$("#trigger").click(function () {
    $("#target").css({display: 'inline-block', transition: '0.5s'});
    var hash = $(this).attr("href","#added-to-the-uri");
    location.hash = hash;
});

But it doesn't generate: xyz.html#added-to-the-uri but this one xyz.html#[object Object]

What do I need to edit for this? Thanks!

Mario Araque

In this line:

var hash = $(this).attr("href","#added-to-the-uri");

You are not setting the #added-to-the-uri to hash variable. You are setting the value of $(this). The attr function returns the $(this) object.

You should add the anchor like this:

$("#trigger").click(function () {
  $("#target").css({display: 'inline-block', transition: '0.5s'});
  location.hash = 'added-to-the-uri';
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to append to div id

How to append custom calendar in CRON URI?

How to append URI as string in SQL query

How to change application id uri?

How to append something like ?id=1 to a NSMutableURLRequest

How to append Function directly to ID in jQuery?

How to get array id in ajax append?

how to append a variable to id of radio button in jquery

How to append div by id using jquery

How to append a a new element in a class using id

How to append html id with for-loop?

How to append the id to the url after assigning the id to the String

How can I take a list of server names and append a resource URI and port to each?

How to get the id of the URI, to insert it to database after submit? Codeigniter

How to design RESTful API URI when you can't have user ID on the URI

How to append data based on class name and div id?

How to append all the elements with the same id in a pandas dataframe row?

how to generate and append the ids/numeric value to the input id attribute in jsp

How to append li items to fisrt ul of given id

How can I give dynamic id in jquery with append tag

How to append without unique auto id firebase swift

How to append user ID to link within Vue Data object

how to append optionValue to the input id and label for attribute dynamically?

How to append a span tag and give each id a new name

How do I append certain elements in Json dictionary based on the ID?

how to get the id value in each row from the append table in JavaScript

How do I send id in array in form append?

Saving String data to SharedPreference then append to Uri

Convert Data URI to File then append to FormData

TOP Ranking

HotTag

Archive