-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 回答