Better yet, make a function that you can reuse:

function contentWidth(obj) {
    var width = obj.wrapInner("<span></span>").children().width();
    obj.html(obj.children().html());
    return width;
}

Now you can use the function like this...

var width = contentWidth($("#myp"));

Reply via email to