-4
<div id="abc" onclick="location.href='/new-data/?asd=asd'">
</div>

私が必要とする出力new-datalocation.href.
jQuery または JavaScript を使用してどのように行うのですか?

4

1 に答える 1

0

div idは「abc」で、onclickの値は常に次の形式であるため、このようなものです

whatever/somedata/whatever

function GetTheContentFromOneSpecialCharacterToAnotherOne()
{
    var the_full_content = document.getElementById('abc').getAttribute('onclick');

    var the_parts = the_full_content.split('/');

    return the_parts[1];
}
于 2013-07-01T11:55:23.227 に答える